feat: add discovery timestamps to deviceInfo#1136
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1136 +/- ##
==========================================
+ Coverage 43.61% 43.68% +0.07%
==========================================
Files 143 144 +1
Lines 13626 13654 +28
==========================================
+ Hits 5943 5965 +22
- Misses 7118 7122 +4
- Partials 565 567 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds discovery timestamp tracking to the v1 DeviceInfo model by introducing an immutable firstDiscovered field and renaming the sync timestamp field from lastUpdated to lastSynced, updating merge behavior and tests to reflect the new semantics.
Changes:
- Add
firstDiscoveredandlastSyncedtodto/v1.DeviceInfo, including JSON compatibility mapping from legacylastUpdatedon input. - Update partial-merge behavior to treat
discovered/firstDiscoveredas write-once fields (when merged via nested field maps). - Refresh unit/integration artifacts (tests, OpenAPI examples, Postman collection) to use the new fields.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/usecase/devices/usecase.go | Adds write-once setters for discovered and firstDiscovered, and maps legacy lastupdated field selection to LastSynced. |
| internal/usecase/devices/repo_test.go | Extends partial-update tests and adds a test asserting immutability of discovered/firstDiscovered during PATCH merges. |
| internal/entity/dto/v1/device.go | Introduces FirstDiscovered and renames LastUpdated → LastSynced, with a custom UnmarshalJSON to accept legacy lastUpdated. |
| internal/entity/dto/v1/device_test.go | Updates round-trip JSON tests and adds coverage for legacy lastUpdated input mapping to LastSynced. |
| internal/controller/openapi/devices.go | Updates example payloads to include firstDiscovered and lastSynced. |
| internal/controller/httpapi/v1/devices_test.go | Updates v1 HTTP tests to send/expect the new JSON fields. |
| integration-test/collections/console_mps_apis.postman_collection.json | Updates Postman request examples to use firstDiscovered and lastSynced. |
89d4360 to
7e08834
Compare
|
Is deviceInfo.lastUpdated consumed anywhere? If not, we rename it to lastSynced and drop the compat mirror (Option 3). The naming options: Option 1 - Keep the name lastUpdated (no rename)
Option 2 - Rename to lastSynced, keep a compatibility mirror (this is the copilot review comment)
Option 3 — Rename to lastSynced, drop the mirror (clean) - current code
Note on the names: top-level is lastUpdate, deviceInfo's old field is lastUpdated — they differ by one letter, so it's not a hard key-collision, but that near-identical pairing is exactly why a distinct name like lastSynced is worth it. |
5ad4331 to
5c0adb7
Compare
|
Hi @sudhir-intc , checked with Madhavi/Ganesh offline on this, Going ahead with option3: does it break the migration flow if we make this change? if not, then we are good to make this change. |
Add firstDiscovered (immutable) and rename lastUpdated to lastSynced. Related to device-management-toolkit/rpc-go#1394
5c0adb7 to
e84a00a
Compare
sudhir-intc
left a comment
There was a problem hiding this comment.
LGTM .. there's one minor comment please take in the suggestion.
e84a00a to
631cb5d
Compare
Add firstDiscovered (immutable) and rename lastUpdated to lastSynced.
Related to device-management-toolkit/rpc-go#1394
Migration matrix:
rpc-go new --> device-management-toolkit/rpc-go#1441
rpc-go old --> latest rpc-go main branch
console new --> #1136
console old --> latest console main branch
Note:
Deploy order: console#1136 must get merged before or with rpc-go#1441 - new rpc against old console loses the timestamps.
firstDiscovered is set once at device creation; updating an existing record won't add it. Delete the record (full deactivation) then re-sync to see it set fresh.