Created
July 16, 2025 18:20
-
-
Save ccerv1/390f05eb0003f64a8d02db44abbd09dd to your computer and use it in GitHub Desktop.
Get monthly contributors from a collection using pyoso
This file contains hidden or 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
| from pyoso import Client | |
| client = Client(YOUR_OSO_API_KEY) | |
| target_collection = "your-collection-name" | |
| start_date, end_date = "2025-01-01", "2025-07-31" | |
| query = f""" | |
| WITH target_artifacts AS ( | |
| SELECT DISTINCT artifact_id | |
| FROM artifacts_by_collection_v1 | |
| WHERE collection_name = '{target_collection}' | |
| ), | |
| events AS ( | |
| SELECT | |
| DATE_TRUNC('month', bucket_day) AS month_start, | |
| from_artifact_id | |
| FROM int_events_daily__github | |
| WHERE bucket_day BETWEEN DATE '{start_date}' AND DATE '{end_date}' | |
| AND event_type IN ('COMMIT_CODE', 'ISSUE_OPENED', 'PULL_REQUEST_OPENED', 'PULL_REQUEST_MERGED') | |
| AND to_artifact_id IN (SELECT artifact_id FROM target_artifacts) | |
| ) | |
| SELECT | |
| month_start, | |
| COUNT(DISTINCT from_artifact_id) AS contributor_count | |
| FROM events | |
| GROUP BY month_start | |
| ORDER BY month_start | |
| """ | |
| result = client.to_pandas(query) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment