-
Notifications
You must be signed in to change notification settings - Fork 36
Add generic SQL queries to allow automatic update #606
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,87 @@ | ||||||||
| # SQL command to get those stats | ||||||||
|
|
||||||||
| Needs to be run via the Galaxy Admin Stats Account | ||||||||
|
|
||||||||
| # tool usage last 5 years | ||||||||
| ```sql | ||||||||
| \set snapshot_date `date '+%Y-%m-01'` | ||||||||
|
|
||||||||
| \copy ( | ||||||||
| SELECT | ||||||||
| DISTINCT REGEXP_REPLACE(j.tool_id, '(.*)/(.*)', '\1') AS tool_name, | ||||||||
| COUNT(*) AS count, | ||||||||
| date_trunc('month', CURRENT_DATE) AS snapshot_date | ||||||||
| FROM job j | ||||||||
| WHERE j.create_time BETWEEN (date_trunc('month', CURRENT_DATE) - INTERVAL '5 years') | ||||||||
| AND date_trunc('month', CURRENT_DATE) | ||||||||
|
Collaborator
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.
Suggested change
|
||||||||
| GROUP BY tool_name | ||||||||
| ORDER BY count DESC | ||||||||
| ) | ||||||||
| TO :'tool_usage_5y_until_' || :'snapshot_date' || '.csv' WITH CSV HEADER; | ||||||||
| ``` | ||||||||
|
|
||||||||
| # tool usage for ever | ||||||||
| ```sql | ||||||||
| \set snapshot_date `date '+%Y-%m-01'` | ||||||||
|
|
||||||||
| \copy ( | ||||||||
| SELECT | ||||||||
| DISTINCT REGEXP_REPLACE(j.tool_id, '(.*)/(.*)', '\1') AS tool_name, | ||||||||
| COUNT(*) AS count, | ||||||||
| date_trunc('month', CURRENT_DATE) AS snapshot_date | ||||||||
| FROM job j | ||||||||
| WHERE j.create_time <= date_trunc('month', CURRENT_DATE) | ||||||||
| GROUP BY tool_name | ||||||||
|
Collaborator
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.
Suggested change
|
||||||||
| ORDER BY count DESC | ||||||||
| ) | ||||||||
| TO :'tool_usage_until_' || :'snapshot_date' || '.csv' WITH CSV HEADER; | ||||||||
|
|
||||||||
| ``` | ||||||||
|
|
||||||||
| # tool users last 5 years | ||||||||
| ```sql | ||||||||
| \set snapshot_date `date '+%Y-%m-01'` | ||||||||
|
|
||||||||
| \copy ( | ||||||||
| SELECT | ||||||||
| tool_name, | ||||||||
| COUNT(*) AS count, | ||||||||
| date_trunc('month', CURRENT_DATE) AS snapshot_date | ||||||||
| FROM ( | ||||||||
| SELECT | ||||||||
| DISTINCT REGEXP_REPLACE(tool_id, '(.*)/(.*)', '\1') AS tool_name, | ||||||||
| user_id | ||||||||
| FROM job | ||||||||
| WHERE create_time BETWEEN (date_trunc('month', CURRENT_DATE) - INTERVAL '5 years') | ||||||||
| AND date_trunc('month', CURRENT_DATE) | ||||||||
|
Collaborator
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.
Suggested change
|
||||||||
| GROUP BY tool_name, user_id | ||||||||
| ) AS subquery | ||||||||
| GROUP BY tool_name | ||||||||
| ORDER BY count DESC | ||||||||
| ) | ||||||||
| TO :'tool_users_5y_until_' || :'snapshot_date' || '.csv' WITH CSV HEADER; | ||||||||
|
|
||||||||
| ``` | ||||||||
|
|
||||||||
| # tool users for ever | ||||||||
| ```sql | ||||||||
| \set snapshot_date `date '+%Y-%m-01'` | ||||||||
|
|
||||||||
| \copy ( | ||||||||
| SELECT | ||||||||
| tool_name, | ||||||||
| COUNT(*) AS count, | ||||||||
| date_trunc('month', CURRENT_DATE) AS snapshot_date | ||||||||
| FROM ( | ||||||||
| SELECT DISTINCT | ||||||||
| REGEXP_REPLACE(tool_id, '(.*)/(.*)', '\1') AS tool_name, | ||||||||
| user_id | ||||||||
| FROM job | ||||||||
| WHERE create_time <= date_trunc('month', CURRENT_DATE) | ||||||||
| GROUP BY tool_name, user_id | ||||||||
|
Collaborator
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.
Suggested change
|
||||||||
| ) AS subquery | ||||||||
| GROUP BY tool_name | ||||||||
| ORDER BY count DESC | ||||||||
| ) | ||||||||
| TO :'tool_users_until_' || :'snapshot_date' || '.csv' WITH CSV HEADER; | ||||||||
| ``` | ||||||||
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.