🔧 feat: Add contract state-based save frequency and menu visibility#1972
🔧 feat: Add contract state-based save frequency and menu visibility#1972
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements contract state-based save frequency throttling and conditionally hides the boost menu during the signup phase. The changes aim to reduce unnecessary database writes during different contract lifecycle stages.
Key Changes:
- Adds time-based save throttling with different intervals for signup (2 minutes) vs. active contracts (15 seconds)
- Hides the boost menu UI component when contracts are in the signup state
- Imports the
timepackage to support the new throttling logic
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/boost/boost_datastore.go | Implements save frequency throttling based on contract state and last save time |
| src/boost/boost_button_reactions.go | Conditionally renders the boost menu only for non-signup contracts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if contract.State == ContractStateSignup { | ||
| if time.Since(contract.LastSaveTime) < 2*time.Minute && contract.CoopSize < len(contract.Boosters) { | ||
| // Only save signup contracts every 2 minutes during signup | ||
| return | ||
| } | ||
| } else { | ||
| if time.Since(contract.LastSaveTime) < 15*time.Second { | ||
| // Only save non-signup contracts every 15 seconds during signup | ||
| return | ||
| } | ||
| } |
There was a problem hiding this comment.
The LastSaveTime field is checked to throttle saves, but it's never updated after a successful save. This means the throttling logic will never work correctly - the first save will work, but subsequent saves will always be skipped because LastSaveTime will remain at its zero value or the last value it was set to. You need to update contract.LastSaveTime = time.Now() after calling saveSqliteData(contract) on line 89.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@mkmccarty I've opened a new pull request, #1973, to work on those changes. Once the pull request is ready, I'll request review from you. |
[WIP] WIP Address feedback from PR #1972 on contract state-based features
No description provided.