-
Notifications
You must be signed in to change notification settings - Fork 878
feat: add total users insight #15486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a20be9f
4e43cc0
24baca9
da5f1b8
e77cf67
7cd2d86
442c75a
bcf91f9
70e66a8
3da408e
639777f
520790d
c011a05
eaac6c1
0e94c74
186a951
d340e2d
82b6c36
81c8038
fac0c68
9ba203c
a85e3f9
6fb880c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -771,3 +771,18 @@ SELECT | |
FROM unique_template_params utp | ||
JOIN workspace_build_parameters wbp ON (utp.workspace_build_ids @> ARRAY[wbp.workspace_build_id] AND utp.name = wbp.name) | ||
GROUP BY utp.num, utp.template_ids, utp.name, utp.type, utp.display_name, utp.description, utp.options, wbp.value; | ||
|
||
-- name: GetAccumulatedUsersInsights :many | ||
-- GetAccumulatedUsersInsights returns the accumulated number of users created | ||
-- in the given timeframe. It returns the accumulated number of users for each date | ||
-- within the specified timeframe, providing a running total of user sign-ups. | ||
SELECT | ||
date_trunc('day', created_at)::date AS date, | ||
COUNT(*) OVER (ORDER BY date_trunc('day', created_at)::date) AS accumulated_users | ||
FROM | ||
users | ||
WHERE | ||
created_at >= @start_time::timestamptz | ||
AND created_at < @end_time::timestamptz | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More for confirmation than a request to change - is it expected to exclude the end_time from the query ? If I say I want the insights from 01/01to 02/01- should we include 02/01 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In-memory DB doesn't match this: if user.CreatedAt.Before(arg.StartTime) || user.CreatedAt.After(arg.EndTime) { Missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No. Not quite, at least. The intention is to include it. We'll generate a series of dates starting from the start date with 24 hour increments. This means that subject to some offset (<24h), the date of the endtime param will be included. |
||
ORDER BY | ||
date_trunc('day', created_at)::date; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might produce strange results if requested start time and end time are in a different timezone. Each day may be missing few/many entries and we might get ghost dates as well (+/-1 day outside start/end range).
Suggestion:
(Untested), why the double at timezone? One strips timezone and the other one adds it back.
Notice +00 and lack thereof. Now notice how we get a timezoneally correct truncation when we do it without timezone:
You might want to use a subquery so you can count over the improved truncation without repeating all that noise.