Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user to flow to StorageFlows table, to record who triggered auto snapshot #4518

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

hardillb
Copy link
Contributor

part of #4413

Description

Records which user triggered the last flow deploy so it can be used in snapshot data.

Related Issue(s)

#4413

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production

Labels

  • Includes a DB migration? -> add the area:migration label

@hardillb hardillb self-assigned this Sep 19, 2024
@hardillb
Copy link
Contributor Author

Need to double check how this behaves when a snapshot is exported/imported

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.08%. Comparing base (417df50) to head (2ea8807).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
forge/db/controllers/ProjectSnapshot.js 80.00% 1 Missing ⚠️
forge/db/migrations/20240920-02-add-flow-user.js 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4518      +/-   ##
==========================================
- Coverage   78.15%   78.08%   -0.07%     
==========================================
  Files         299      301       +2     
  Lines       14261    14299      +38     
  Branches     3235     3243       +8     
==========================================
+ Hits        11145    11165      +20     
- Misses       3116     3134      +18     
Flag Coverage Δ
backend 78.08% <86.66%> (-0.07%) ⬇️

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.

@hardillb hardillb marked this pull request as ready for review September 20, 2024 10:17
@hardillb
Copy link
Contributor Author

Needs nr-launcher pr FlowFuse/nr-launcher#287

@knolleary
Copy link
Member

Note we now have #4526 that also contains a migration. Whichever merges first, the other one will need to rename its migration to ensure the ordering is correct.

@hardillb
Copy link
Contributor Author

I have renamed the migration in this PR to 02 so merge the OTHER PR first

@@ -25,14 +25,20 @@ module.exports = async function (app) {

app.post('/:projectId/flows', async (request, response) => {
const id = request.params.projectId
let UserId = null
if (request.headers['ff-user']) {
UserId = app.db.models.User.decodeHashid(request.headers['ff-user'])[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
UserId = app.db.models.User.decodeHashid(request.headers['ff-user'])[0]
UserId = app.db.models.User.decodeHashid(request.headers['ff-user'])?.[0] || null

Comment on lines +13 to +16
// CHECK ME
onDelete: 'SET NULL',
// CHECK ME
onUpdate: 'CASCADE'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// CHECK ME
onDelete: 'SET NULL',
// CHECK ME
onUpdate: 'CASCADE'
onDelete: 'SET NULL',
onUpdate: 'CASCADE'

happy with cascades

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