Add content_modified field to dandiset API responses#2723
Draft
bendichter wants to merge 3 commits intodandi:masterfrom
Draft
Add content_modified field to dandiset API responses#2723bendichter wants to merge 3 commits intodandi:masterfrom
bendichter wants to merge 3 commits intodandi:masterfrom
Conversation
The listing and detail endpoints were returning the dandiset's auto-updated `modified` field, which can be stale by years since it only updates when the Dandiset ORM model itself is saved. The version's `modified` field is the one that actually tracks content changes (metadata edits, asset add/remove). Changes: - Populate `dateModified` in version metadata from version.modified, matching `dateCreated` which was already populated from dandiset.created - Override `modified` in DandisetListSerializer and DandisetDetailSerializer to return the most recent version's modified timestamp - Add tests for the corrected behavior No new database fields or migrations needed. The ordering filter already used a subquery to sort by version modified, so ordering continues to work correctly. Addresses dandi#458, dandi#1227, dandi#1864 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a2cfe15 to
9492306
Compare
Drop the _populate_metadata() dateModified change and its test — the schema field should not be modified here. Keep the serializer overrides that make the API's `modified` field reflect the version's modified timestamp (content change time) rather than the dandiset's stale one. Also tighten bare except to Version.DoesNotExist. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a new content_modified field to the list and detail endpoints that returns the most recent version's modified timestamp, representing when the dandiset's content was last meaningfully changed. This is additive and non-breaking — the existing modified field remains unchanged. Also support ordering=content_modified / -content_modified in the listing endpoint. The existing ordering=modified continues to work with the same behavior (sorting by version modified). Addresses dandi#458, dandi#1227, dandi#1864 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Add a new
content_modifiedfield to the dandiset list and detail API endpoints that returns the most recent version'smodifiedtimestamp — representing when the dandiset's content was last meaningfully changed (metadata edits, asset add/remove).This is additive and non-breaking: the existing
modifiedfield remains unchanged (still the dandiset model's own auto-updated timestamp). Also supportsordering=content_modified/-content_modifiedin the listing endpoint.Changes (2 production files, no migration)
views/serializers.py: Addcontent_modifiedSerializerMethodField toDandisetListSerializerandDandisetDetailSerializerviews/dandiset.py: Addcontent_modifiedtoDandisetOrderingFilterAddresses #458, #1227, #1864
Test plan
content_modifiedin list endpoint reflects the draft version's modification timecontent_modifiedin retrieve endpoint reflects the draft version's modification timeordering=content_modified/-content_modifiedsorts correctlymodifiedfield is unchanged🤖 Generated with Claude Code