Skip to content

feat: expose insights into user activity #9807

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

Merged
merged 26 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix: combined
  • Loading branch information
mtojek committed Sep 22, 2023
commit e2077825b29d3453efa761333752a9c1168209cc
13 changes: 3 additions & 10 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 3 additions & 10 deletions coderd/database/queries/insights.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,22 @@ WITH app_stats AS (
start_time,
seconds
FROM app_stats
UNION ALL
UNION
SELECT
user_id,
template_id,
start_time,
seconds
FROM session_stats
), distinct_combined_stats AS (
SELECT DISTINCT
user_id,
template_id,
start_time,
seconds
FROM combined_stats
)
SELECT
users.id as user_id,
users.username,
users.avatar_url,
array_agg(DISTINCT template_id)::uuid[] AS template_ids,
SUM(seconds) AS usage_seconds
FROM distinct_combined_stats
JOIN users ON (users.id = distinct_combined_stats.user_id)
FROM combined_stats
JOIN users ON (users.id = combined_stats.user_id)
GROUP BY users.id, username, avatar_url
ORDER BY user_id ASC;

Expand Down