Add a usage last update field to calculate avoiding double-counting#18
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new usage_last_update field to the Analysis model and updates the CPU hours calculation to avoid double‐counting by leveraging this new field. It also refactors database access to use a transaction-aware query accessor and updates related dependency versions.
- Introduces the usage_last_update field in the Analysis struct and updates relevant SQL queries.
- Refactors database calls to use the d.Q() helper for transaction support.
- Enhances CPU hours calculation by returning a structured CalculationResult and updating the usage_last_update field after each calculation.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| main.go | Adds a TODO note regarding when the CPU hours calculation should run. |
| go.mod | Updates dependency version for github.com/cyverse-de/p/go/qms. |
| db/workers.go | Updated database access calls to use the Q() method for transaction support. |
| db/events.go | Updated database access calls to use the Q() method consistently. |
| db/db.go | Introduces transaction helper methods (Begin, Commit, Rollback) and Q() func. |
| db/analyses.go | Adds usage_last_update to the Analysis struct and a new SetUsageLastUpdate fn. |
| cpuhours/cpuhours.go | Refactors CPU hours calculation to use CalculationResult and updates usage_last_update. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
4c1bc10 to
28c27e7
Compare
Member
Author
|
I'm going to go ahead and merge this for testing. Reviews still welcome and encouraged. |
ianmcorvidae
added a commit
that referenced
this pull request
Jul 8, 2025
This reverts commit 79e03b4.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have a feeling there's subtle issues here I haven't sorted out yet, but I think it's to a state of basically working.
Depends on cyverse/qms#67 on the other end for the metadata parts.