Skip to content

Add a usage last update field to calculate avoiding double-counting#18

Merged
ianmcorvidae merged 1 commit into
cyverse-de:mainfrom
ianmcorvidae:usage-calc-dedup
Jun 23, 2025
Merged

Add a usage last update field to calculate avoiding double-counting#18
ianmcorvidae merged 1 commit into
cyverse-de:mainfrom
ianmcorvidae:usage-calc-dedup

Conversation

@ianmcorvidae

Copy link
Copy Markdown
Member

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread db/analyses.go Outdated
Comment thread cpuhours/cpuhours.go Outdated
Comment thread cpuhours/cpuhours.go Outdated
@socket-security

socket-security Bot commented Jun 13, 2025

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgithub.com/​cyverse-de/​p/​go/​qms@​v0.2.0 ⏵ v0.2.199 +110010010050 -50

View full report

@ianmcorvidae

Copy link
Copy Markdown
Member Author

I'm going to go ahead and merge this for testing. Reviews still welcome and encouraged.

@ianmcorvidae ianmcorvidae merged commit 38831e7 into cyverse-de:main Jun 23, 2025
3 checks passed
ianmcorvidae added a commit that referenced this pull request Jul 2, 2025
This reverts commit 38831e7, reversing
changes made to 95c009b.
ianmcorvidae added a commit that referenced this pull request Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants