-
Notifications
You must be signed in to change notification settings - Fork 66
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
Implement history timeline API (backend) #4509
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4509 +/- ##
==========================================
+ Coverage 78.15% 78.20% +0.05%
==========================================
Files 299 302 +3
Lines 14261 14354 +93
Branches 3235 3261 +26
==========================================
+ Hits 11145 11226 +81
- Misses 3116 3128 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@cstns some sample data from the API for your consideration when working on the front-end... A request for 5 items, no cursor
{
"meta": {
"next_cursor": "2aDOkWmDMb"
},
"count": 5,
"timeline": [
{
"id": "MqDZqRA8P7",
"createdAt": "2024-09-18T11:58:29.054Z",
"user": {
"id": "system",
"username": "System",
"name": "FlowFuse Platform",
"avatar": "/avatar/camera.svg"
},
"event": "project.snapshot.created",
"data": {
"snapshot": {
"id": "J5yD3kEDr9",
"name": "Auto Snapshot - 2024-09-18 12:58:28",
"description": "Instance Auto Snapshot taken following a Modified Nodes deployment"
},
"info": {
"snapshotExists": true
}
}
},
{
"id": "qVYl7ZND7p",
"createdAt": "2024-09-18T11:58:28.966Z",
"user": {
"id": "EexY4j17B2",
"username": "steve",
"name": "steve-mcl",
"avatar": "http://192.168.86.45:3000/avatar/c3RldmU"
},
"event": "flows.set",
"data": {
"flowsSet": {
"type": "nodes"
}
}
},
{
"id": "WjYXGWRD3d",
"createdAt": "2024-09-17T18:55:20.099Z",
"user": {
"id": "EexY4j17B2",
"username": "steve",
"name": "steve-mcl",
"avatar": "http://192.168.86.45:3000/avatar/c3RldmU"
},
"event": "project.snapshot.imported",
"data": {
"sourceProject": {
"id": "178e4d8a-4075-4647-9e62-8fe3eba65dec",
"name": "prod"
},
"snapshot": {
"id": "x17DdQpgKb",
"name": "a copy of dashboard soc - Deploy Snapshot - 2024-09-17 19:55:17",
"description": "Snapshot created for pipeline deployment from src to dst as part of pipeline test"
},
"info": {
"snapshotExists": true
}
}
},
{
"id": "dz8p43P8xK",
"createdAt": "2024-09-17T18:51:29.307Z",
"user": {
"id": "EexY4j17B2",
"username": "steve",
"name": "steve-mcl",
"avatar": "http://192.168.86.45:3000/avatar/c3RldmU"
},
"event": "project.settings.updated",
"data": {
"updates": [
{
"key": "header.title",
"old": "dashboard-soc",
"new": "dashboard-soc2",
"dif": "updated"
}
]
}
},
{
"id": "2aDOkWmDMb",
"createdAt": "2024-09-17T18:48:37.803Z",
"user": {
"id": "EexY4j17B2",
"username": "steve",
"name": "steve-mcl",
"avatar": "http://192.168.86.45:3000/avatar/c3RldmU"
},
"event": "project.snapshot.rolled-back",
"data": {
"snapshot": {
"id": "Q2YDLwlO9M",
"name": "new 1",
"description": ""
},
"info": {
"snapshotExists": true
}
}
}
]
} A request for 100, but the cursor is near the end of the data
{
"meta": {},
"count": 2,
"timeline": [
{
"id": "MqDZ75AYP7",
"createdAt": "2024-07-06T06:36:34.483Z",
"user": {
"id": "EexY4j17B2",
"username": "steve",
"name": "steve-mcl",
"avatar": "http://192.168.86.45:3000/avatar/c3RldmU"
},
"event": "flows.set",
"data": {
"flowsSet": {
"type": "full"
}
}
},
{
"id": "568ryyAgO3",
"createdAt": "2024-05-30T10:55:27.170Z",
"user": {
"id": "EexY4j17B2",
"username": "steve",
"name": "steve-mcl",
"avatar": "http://192.168.86.45:3000/avatar/c3RldmU"
},
"event": "project.created",
"data": {
"team": {
"id": "2VJ1bDYopr",
"name": "Team team",
"slug": "team1",
"type": null
}
}
}
]
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some feedback on the implementation around scalability of db queries.
But I have some more fundamental questions around why a separate API is needed above the existing /audit-log
end point which could be extended to include the additional meta information - #4424 (comment)
Maybe a quick chat would be helpful to clarify this.
discussion notes:
|
… into 4424-history-api
@knolleary after much ado, the unit tests are now passing. FYI, The test runner was too fast and audit entries had the same timestamp causing the sort ordering to go by ID ASC when 2 timestamps were the same. We can leave the API returning results by ID DESC or introduce small delays in the test runner to simulate more realistic operational logging. What do you think? |
I vote add delay to test, but are we 100% that it's impossible to go that fast in real life? |
Not 100% certain that consecutive entries coulndt occur but it is very unlikely. Perhaps then order by |
Real-life doesn't matter here; two events happening in the same millisecond won't matter to the user what order they are reported in the log. The test however is making assumptions about the order. So either guarantee the order or make the test more flexible to cope with the variable ordering |
@Steve-Mcl if a flow is set via a DevOps Pipeline, what event lists in this response? |
'project.created', |
closes #4424
Description
forge/routes/api/project.js
so it can be used by EE and NON EE routesforProjectHistory
toforge/db/models/AuditLog.js
for querying audit logs for a projects timelineforge/db/views/AuditLog.js
description
fieldproject:history
GET /projects/:projectId/history
in the EE sectionforge/ee/routes/projectHistory/index.js
projectHistory
Tests
test/unit/forge/ee/routes/api/project_spec.js
test/unit/forge/routes/api/project_spec.js
TODO:
Related Issue(s)
#4424
Checklist
flowforge.yml
?FlowFuse/helm
to update ConfigMap TemplateFlowFuse/CloudProject
to update values for Staging/ProductionLabels
area:migration
label