Skip to content

Add content_modified field to dandiset API responses#2723

Draft
bendichter wants to merge 3 commits intodandi:masterfrom
bendichter:feature/content-modified
Draft

Add content_modified field to dandiset API responses#2723
bendichter wants to merge 3 commits intodandi:masterfrom
bendichter:feature/content-modified

Conversation

@bendichter
Copy link
Member

@bendichter bendichter commented Mar 5, 2026

Summary

Add a new content_modified field to the dandiset list and detail API endpoints that returns the most recent version's modified timestamp — representing when the dandiset's content was last meaningfully changed (metadata edits, asset add/remove).

This is additive and non-breaking: the existing modified field remains unchanged (still the dandiset model's own auto-updated timestamp). Also supports ordering=content_modified / -content_modified in the listing endpoint.

Changes (2 production files, no migration)

  • views/serializers.py: Add content_modified SerializerMethodField to DandisetListSerializer and DandisetDetailSerializer
  • views/dandiset.py: Add content_modified to DandisetOrderingFilter

Addresses #458, #1227, #1864

Test plan

  • Verify content_modified in list endpoint reflects the draft version's modification time
  • Verify content_modified in retrieve endpoint reflects the draft version's modification time
  • Verify ordering=content_modified / -content_modified sorts correctly
  • Verify existing modified field is unchanged

🤖 Generated with Claude Code

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>
@bendichter bendichter force-pushed the feature/content-modified branch from a2cfe15 to 9492306 Compare March 5, 2026 15:02
@bendichter bendichter changed the title Add content_modified field to Dandiset model Fix modified timestamps in API responses and populate dateModified in schema Mar 5, 2026
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>
@bendichter bendichter changed the title Fix modified timestamps in API responses and populate dateModified in schema Return version modified timestamp in dandiset API responses Mar 9, 2026
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>
@bendichter bendichter changed the title Return version modified timestamp in dandiset API responses Add content_modified field to dandiset API responses Mar 9, 2026
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.

1 participant