Skip to content
Open
Changes from all commits
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
87 changes: 87 additions & 0 deletions sources/data/usage_stats/README.md
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Needs to be run via the Galaxy Admin Stats Account
Needs to be run via the Galaxy Admin Stats Account
For people who do not have access to the Galaxy Admin Stats Account :
1. Reach out to an admin
2. Provide them with the SQL queries (or a link to this page)
Once the files have been generated :
1. Create a new folder in the [folder sources/data/usage_stats of the galaxy_codex repository](https://github.com/galaxyproject/galaxy_codex/tree/main/sources/data/usage_stats)
2. Name the folder 'usage_stats_YYYY.MM.DD'
3. Within this folder, create a subfolder indicating the instance where the data are coming from (eu, fr, org, or org.au)
4. Drop the csv file(s) in the appropriate folder


# 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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AND date_trunc('month', CURRENT_DATE)
AND date_trunc('month', CURRENT_DATE) AND j.state != 'deleted'

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GROUP BY tool_name
AND j.state != 'deleted'
GROUP BY tool_name

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AND date_trunc('month', CURRENT_DATE)
AND date_trunc('month', CURRENT_DATE) AND j.state != 'deleted'

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GROUP BY tool_name, user_id
AND j.state != 'deleted'
GROUP BY tool_name, user_id

) AS subquery
GROUP BY tool_name
ORDER BY count DESC
)
TO :'tool_users_until_' || :'snapshot_date' || '.csv' WITH CSV HEADER;
```
Loading