-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from jharrell/add-typedsql
add TypedSQL feature for Prisma
- Loading branch information
Showing
7 changed files
with
9,992 additions
and
13,468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
WITH date_range AS ( | ||
SELECT generate_series( | ||
(SELECT DATE_TRUNC('day', MIN("createdAt")) FROM contacts), | ||
DATE_TRUNC('day', NOW()) + INTERVAL '1 day', | ||
INTERVAL '1 day' | ||
) AS day | ||
) | ||
|
||
SELECT | ||
dr.day, | ||
SUM(COALESCE(ct.count, 0)) OVER (ORDER BY dr.day) as count | ||
FROM date_range dr | ||
LEFT JOIN ( | ||
SELECT | ||
DATE_TRUNC('day', c."createdAt") AS day, | ||
COUNT(c.id) as count | ||
FROM contacts c | ||
WHERE "projectId" = $1 | ||
GROUP BY DATE_TRUNC('day', c."createdAt") | ||
) ct ON dr.day = ct.day | ||
WHERE dr.day < DATE_TRUNC('day', NOW()) | ||
ORDER BY dr.day DESC | ||
LIMIT 30; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT clicks."link", a."name", count(clicks.id)::int FROM clicks | ||
JOIN emails e on clicks."emailId" = e.id | ||
JOIN actions a on e."actionId" = a.id | ||
WHERE clicks."link" NOT LIKE '%unsubscribe%' AND DATE(clicks."createdAt") BETWEEN DATE($1) AND DATE($2) AND a."projectId" = $3 | ||
GROUP BY a."name", clicks."link" |
Oops, something went wrong.