Skip to content

COM: last_modified not updating after transforms#245

Open
meghanagottapu wants to merge 3 commits intoc2siorg:mainfrom
meghanagottapu:feature/dateTime_audit
Open

COM: last_modified not updating after transforms#245
meghanagottapu wants to merge 3 commits intoc2siorg:mainfrom
meghanagottapu:feature/dateTime_audit

Conversation

@meghanagottapu
Copy link
Copy Markdown

@meghanagottapu meghanagottapu commented Mar 30, 2026

Description

The Project model has a last_modified column used to order the homescreen 'Recently Modified' list. Before this fix, last_modified was only stamped at project creation - it was never updated when a transformation was applied. This meant the homescreen always ordered projects by upload time, not by actual activity. Projects you were actively working on would sink below projects that were uploaded more recently but untouched.

Root Cause

The root cause was in project_service.log_transformation(): it wrote a ProjectChangeLog row and committed, but never touched the parent Project row. The fix adds four lines that fetch the parent Project and stamp last_modified = datetime.now(timezone.utc) in the same commit.

Fixes #244

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

How Has This Been Tested?

A new test file has been added: tests/test_last_modified.py - 6 tests at the service layer

  • test_last_modified_advances_after_one_transform - timestamp strictly later after one logged transform
  • test_last_modified_advances_after_multiple_transforms - timestamps increase strictly across 3 sequential transforms
  • test_last_modified_is_set_to_utc_datetime - value is a Python datetime, not None
  • test_most_recently_transformed_project_appears_first_in_recent - project A, transformed after project B was created, leads /recent
  • test_log_transformation_creates_change_log_entry - the ProjectChangeLog row is still written correctly
  • test_log_transformation_with_unknown_project_id_does_not_raise - the if project: guard is safe for non-existent IDs

Describe the tests you ran to verify your changes.

  • Existing tests pass
  • New tests added
  • Manual testing

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review
  • I have added/updated documentation as needed
  • My changes generate no new warnings
  • Tests pass locally

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

PR Review

Squash

Your PR has 3 commits. Please squash into a single commit.

How to fix

git fetch origin
git rebase -i origin/main   # mark all but first commit as "squash"
git push --force-with-lease

This comment updates automatically on each push.

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.

[Bug] last_modified not updating after transforms

1 participant