GitHub user Thanatos9404 added a comment to the discussion: GitHub Copilot 
Credits no user-specific data

Short answer: with the current code that table can only be filled by a 
connection that has neither an enterprise nor an organization, and connection 
validation rejects that, so for every valid connection it stays empty.

On main (625e512a), in `backend/plugins/gh-copilot`:

- 
[`tasks/ai_credit_collector.go#L51-L58`](https://github.com/apache/devlake/blob/625e512a49966a5814793276474c812204c825ef/backend/plugins/gh-copilot/tasks/ai_credit_collector.go#L51-L58)
 uses the enterprise endpoint when the connection has an enterprise, otherwise 
the organization endpoint, and only falls back to 
`user/settings/billing/ai_credit/usage` when both are empty.
- 
[`tasks/ai_credit_extractor.go#L165-L172`](https://github.com/apache/devlake/blob/625e512a49966a5814793276474c812204c825ef/backend/plugins/gh-copilot/tasks/ai_credit_extractor.go#L165-L172)
 writes `_tool_copilot_user_ai_credit_usage` only in that same fallback branch, 
and sets `User` to the connection's display name, not a GitHub login.
- 
[`api/connection.go#L97`](https://github.com/apache/devlake/blob/625e512a49966a5814793276474c812204c825ef/backend/plugins/gh-copilot/api/connection.go#L97)
 rejects a connection without either: "either enterprise or organization is 
required".

So the user table is unreachable today. The org and enterprise tables have a 
`User` column too, but it is always empty as well: the extractor builds its 
wrapper from the connection and never sets `wrapper.User` 
([L93-L96](https://github.com/apache/devlake/blob/625e512a49966a5814793276474c812204c825ef/backend/plugins/gh-copilot/tasks/ai_credit_extractor.go#L93-L96)).
 Getting per-user credit numbers would need the collector to request usage per 
user; right now it only collects org-wide or enterprise-wide totals.


GitHub link: 
https://github.com/apache/devlake/discussions/9161#discussioncomment-19271515

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to