Skip to content

Conversation

matejkubinec
Copy link
Contributor

@matejkubinec matejkubinec commented Sep 15, 2025

PMM-14253

Link to the Feature Build: SUBMODULES-4038

If this PR adds or removes or alters one or more API endpoints, please review and add or update the relevant API documents as well:

  • API Docs updated

If this PR is related to some other PRs in this or other repositories, please provide links to those PRs:

  • Links to related pull requests (optional).

Copy link

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 25.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.98%. Comparing base (320403c) to head (00f5a8b).

Files with missing lines Patch % Lines
managed/models/user_flags_helpers.go 0.00% 4 Missing ⚠️
managed/models/user_flags_model_reform.go 42.85% 4 Missing ⚠️
managed/services/user/user.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                       @@
##           PMM-13652-native-navigation    #4525      +/-   ##
===============================================================
- Coverage                        44.98%   44.98%   -0.01%     
===============================================================
  Files                              356      356              
  Lines                            44808    44813       +5     
===============================================================
+ Hits                             20157    20158       +1     
- Misses                           22999    23002       +3     
- Partials                          1652     1653       +1     
Flag Coverage Δ
admin 17.48% <ø> (ø)
agent 53.30% <ø> (+0.01%) ⬆️
vmproxy 73.45% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@matejkubinec
Copy link
Contributor Author

matejkubinec commented Sep 24, 2025

@idoqo @ademidoff

Hello, would like some feedback on the BE part of this.

I've added a separate snooze updates api endpoint which handled the logic related to snoozing:

  1. Keeps a timestamp of when was the update last snoozed
  2. Mismatch version - resets snooze counter
  3. Increments snooze counter if current snoozed version & payload one matches

Also I've extended settings with snooze duration (currently 7 days) - time after snooze for which an update modal is not shown to the user (configurable via env variable - maybe just for QAs?)


What's missing:

  • Validation for the snooze duration
  • Unit tests/code coverage

EDIT:
Maybe one improvement that I'm currently thinking of, since snooze is user specific would an api route like POST /users/me:snoozeUpdate make more sense rather tha having one under server/updates:snooze?

description: "Returns PMM Server update status."
};
}
// SnoozeUpdate snoozes updates for currently logged in user and returns the count and timestamp
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// SnoozeUpdate snoozes updates for currently logged in user and returns the count and timestamp
// SnoozeUpdate snoozes updates for an authenticated user and returns the count and timestamp

optional bool enable_backup_management = 12;
// Enable Access Control
optional bool enable_access_control = 13;
// A number of full days for which an update is snoozed. Should have a suffix in JSON: 2592000s, 43200m, 720h.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// A number of full days for which an update is snoozed. Should have a suffix in JSON: 2592000s, 43200m, 720h.
// A number of full days for which an update is snoozed, i.e. a multiple of 24h: 2592000s, 43200m, 720h.

I wonder if it wouldn't be easier to provide an uint here? That'd be simple to read and test, no?

string snoozed_pmm_version = 4;
reserved 5;
google.protobuf.Timestamp snoozed_at = 6;
uint32 snoozed_count = 7;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
uint32 snoozed_count = 7;
uint32 snooze_count = 7;

},
112: {
`UPDATE settings
SET settings = settings || '{"updates": {"snooze_duration": 604800000000000}}'
Copy link
Member

Choose a reason for hiding this comment

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

Let's provide a comment here, i.e. how many days it is.

Copy link
Member

Choose a reason for hiding this comment

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

Is it 7?

}, nil
}

// Snooze updates for specific pmm version for current user
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Snooze updates for specific pmm version for current user
// SnoozeUpdate snoozes the updates for specific pmm version for current user.

return nil, err
}

var snoozedAt *timestamppb.Timestamp
Copy link
Member

Choose a reason for hiding this comment

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

If you put this block past line 85, there will be no need to define the variable.

if req.SnoozedPmmVersion != nil {

// Keep for backwards compatibility, prefer the new snooze updates:endpoint
if req.SnoozedPmmVersion != nil && req.SnoozedPmmVersion != &userInfo.SnoozedPMMVersion {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should check the values here, not the pointers, since pointers will be different.

return nil, e
}

var snoozedAt *timestamppb.Timestamp
Copy link
Member

Choose a reason for hiding this comment

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

Same - let's put this block after line 143.

continue
}
envSettings.EnableUpdates = &b
case "PMM_UPDATES_SNOOZE_DURATION":
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
case "PMM_UPDATES_SNOOZE_DURATION":
case "PMM_UPDATE_SNOOZE_DURATION":

}
envSettings.EnableUpdates = &b
case "PMM_UPDATES_SNOOZE_DURATION":
if envSettings.UpdatesSnoozeDuration, err = parseStringDuration(v); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if envSettings.UpdatesSnoozeDuration, err = parseStringDuration(v); err != nil {
if envSettings.UpdateSnoozeDuration, err = parseStringDuration(v); err != nil {

string snoozed_pmm_version = 4;
reserved 5;
google.protobuf.Timestamp snoozed_at = 6;
uint32 snoozed_count = 7;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
uint32 snoozed_count = 7;
uint32 snooze_count = 7;

return resp, nil
}

// SnoozeUpdate snoozes the updates for specific pmm version for current user

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
Comment should end in a period (godot)

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.

3 participants