Expose project created date via API#6096
Open
ChrisJr404 wants to merge 1 commit into
Open
Conversation
Resolves DependencyTrack#6094 Adds a CREATED column to the PROJECT table and exposes it on Project JSON responses. Existing rows have no creation timestamp recorded; the column is nullable so backfill is not required. Signed-off-by: ChrisJr404 <chris@hacknow.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #6094.
The
Projectentity did not track a creation timestamp, soGET /api/v1/project/{uuid}had no way to surface when a project was first created. This adds aCREATEDcolumn to thePROJECTtable and serializes it ascreated(UNIX epoch milliseconds) onProjectresponses, matching the existing convention used bylastBomImportandlastVulnerabilityAnalysis.Changes
Project.java: newcreatedfield with@Column(name = "CREATED", allowsNull = "true")and@Schemamatching the other epoch-millis date fields. Nullable so existing rows are not affected on schema upgrade.ProjectQueryManager#createProject(Project, Collection<Tag>, boolean): stampscreated = new Date()if not already set.ProjectQueryManager#clone(...): stampscreatedon the cloned project (the clone is a new project, so it gets its own creation timestamp rather than inheriting the source's).No DB migration is included. The column is nullable, so DataNucleus' schema auto-update handles the column add for existing deployments. Existing rows will have
created = nulluntil they are next written; this is documented above and behaves the same waylastInheritedRiskScoreand similar additive nullable columns have shipped historically (seeLAST_RISKSCOREcomment inProject.java). If maintainers prefer an explicit backfill via anUpgradeItem, happy to add one.Tests
ProjectQueryManagerTest#testCreateProjectSetsCreatedDate— assertscreateProject(...)setscreatedto the current time.ProjectQueryManagerTest#testCloneProjectSetsCreatedDate— asserts a cloned project gets a freshcreated, not the source's.ProjectResourceTest#getProjectByUuidExposesCreatedDateTest— assertscreatedis present onGET /api/v1/project/{uuid}and is a number within the request window.createProjectandpatchProjectJSON assertions inProjectResourceTestupdated to include"created": "${json-unit.any-number}".Local:
mvn -P enhance test -Dtest='ProjectQueryManagerTest,ProjectResourceTest,ComponentResourceTest,BomResourceTest,BomUploadProcessingTaskTest,WebhookPublisherTest,JiraPublisherTest,ScheduledNotificationDispatchTaskTest'— all 297 tests pass.DCO
Signed-off-by trailer present on the commit.