Skip to content
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

support for persistent data #15

Open
billimek opened this issue Apr 23, 2024 · 3 comments
Open

support for persistent data #15

billimek opened this issue Apr 23, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@billimek
Copy link

As documented, the API contains metrics for the prior 28 days. It would be useful if there would be a way to configure this to support a 'local' json file containing longer-term data (e.g. we currently periodically merge the results into a larger json file with more historical data). Or, perhaps, support an external datasource where the API results are collected and persisted for a longer historical view.

@Myzel394
Copy link

(e.g. we currently periodically merge the results into a larger json file with more historical data

Offtopic: How do you archive the data? Do you use an open source tool or do you just call the api everyday and save its data?

@martedesco
Copy link
Collaborator

Thanks for your feedback @billimek

support an external datasource where the API results are collected and persisted for a longer historical view.

This is something that is being considered for a next phase.

@martedesco martedesco added the enhancement New feature or request label Apr 25, 2024
@billimek
Copy link
Author

Offtopic: How do you archive the data? Do you use an open source tool or do you just call the api everyday and save its data?

It's just a call to the API and merging it with an existing json file. This is how we're now handling this, via a GitHub action workflow, to override the original mocked data json as an interim way to have longer-lived persisted data:

DATE=$(date +"%Y%m%d")
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer ${{ secrets.COPILOT_TOKEN }}" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/orgs/<our org>/copilot/usage > data_${DATE}.json
jq -s 'add | unique_by(.day) | sort_by(.day)' data_${DATE}.json src/assets/copilot_metrics_response_sample.json > data_merged_${DATE}.json && mv data_merged_${DATE}.json src/assets/copilot_metrics_response_sample.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants