This application tracks events from up to a given number of GitHub repositories using the GitHub Events API. It collects events and stores them locally in a SQLite database to minimize API requests and to retain data across restarts. The REST API provides statistics based on a rolling window defined by either a given number of days or a given number of events (whichever is less). Specifically, for each repository and event type combination, the API returns the average time (in seconds) between consecutive events.
- Configurable Repositories: Monitor up to a given number repositories by listing them in
config.json. - Rolling Window Statistics: For each repository and event type, statistics are computed from events in the last given number of days (or the latest given number of events, if fewer).
- REST API Endpoint: A GET endpoint at
/statsreturns the average time interval between events. - Data Persistence: All fetched events are stored in a local SQLite database (
events.db), ensuring data is retained between restarts. - Efficient GitHub API Usage: The application minimizes requests by periodically polling and ignoring duplicate events.
- The GitHub Events API endpoint
https://api.github.com/repos/{repo}/eventsis used without authentication (which has lower rate limits). In a production setting, you might consider using authenticated requests. - The rolling window is defined as events that occurred in the last {7} days. If more than {500} events occur within that period, only the most recent {500} are used for the statistics.
- Event timestamps are assumed to be in ISO 8601 format (as provided by GitHub) and are stored as UTC.
- For simplicity, error handling is basic. In production, you might add retries, exponential backoff, and more robust error logging.
- The application uses APScheduler to poll GitHub every {60} seconds.
- Python 3.11 or higher
pip(Python package installer)
-
Clone the repository or download the project files.
-
Install dependencies:
pip install -r requirements.txt
-
Configure Repositories:
Edit the config.json file to list the GitHub repositories you wish to monitor. For example:
{ "repositories": [ "torvalds/linux", "psf/requests", "..." ] } -
Run the app:
python .\app.py -
Check results:
http://127.0.0.1:5000/stats