Skip to content

feat(traits): add updated_at to Trait - #8665

Open
gagantrivedi wants to merge 5 commits into
mainfrom
feat/trait-updated-at
Open

gagantrivedi wants to merge 5 commits into
mainfrom
feat/trait-updated-at

Conversation

@gagantrivedi

@gagantrivedi gagantrivedi commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to Flagsmith/edge-proxy-rs#14

Adds a nullable updated_at column to environments_trait. The Edge Proxy will write traits straight to Core's database and resolve concurrent writes (retries, multiple regions) with last-write-wins on this timestamp. Core's own trait writes need to stamp it as well, so the proxy compares against real values.

  • Trait.updated_at: DateTimeField(auto_now=True, null=True).
  • Identity.update_traits(): sets updated_at explicitly on changed traits, since bulk_update() skips auto_now; added to BULK_UPDATE_FIELDS.
  • Migration traits.0003_trait_updated_at: adds the column as a plain nullable DateTimeField, then alters it to auto_now=True. Existing rows stay NULL (no backfill)

How did you test this code?

  • New unit test: update_traits stamps updated_at on changed and new traits and leaves unchanged traits alone.

@vercel

vercel Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
docs Ignored Ignored Preview Oct 11, 2026 3:01am UTC
flagsmith-frontend-preview Ignored Ignored Preview Oct 11, 2026 3:01am UTC
flagsmith-frontend-staging Ignored Ignored Preview Oct 11, 2026 3:01am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 1f73ada0-be15-4250-9b66-c7dd016eec22

📥 Commits

Reviewing files that changed from the base of the PR and between 759f724 and 65567a7.


📒 Files selected for processing (4)
  • api/environments/identities/models.py
  • api/environments/identities/traits/migrations/0003_trait_updated_at.py
  • api/environments/identities/traits/models.py
  • api/tests/unit/environments/identities/test_unit_identities_models.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.



📝 Walkthrough

Walkthrough

Trait now has a nullable updated_at field. When Identity.update_traits changes an existing trait, it sets updated_at before the bulk update. Unit tests cover timestamp creation, refresh after a change, and retention for an unchanged trait.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes


Merge Risk: ⚪ Minimal · up to 65567

Traits gain a nullable last-updated timestamp. The timestamp is set when traits are created or changed and kept when they are unchanged. No concrete regression or data-integrity risk was found, so the change appears ready to merge.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added api Issue related to the REST API feature New feature or request labels Oct 3, 2026
@codecov

codecov Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.85%. Comparing base (5c3ba28) to head (65567a7).
⚠️ Report is 21 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #8665    +/-   ##
========================================
  Coverage   98.84%   98.85%            
========================================
  Files        1653     1666    +13     
  Lines       68219    68787   +568     
========================================
+ Hits        67429    67997   +568     
  Misses        790      790            

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Oct 11, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Oct 11, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Oct 11, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Oct 11, 2026
@gagantrivedi
gagantrivedi marked this pull request as ready for review October 11, 2026 03:03
@gagantrivedi
gagantrivedi requested a review from a team as a code owner October 11, 2026 03:03
@gagantrivedi
gagantrivedi requested review from a team, emyller and matthewelwell and removed request for a team October 11, 2026 03:03
@github-actions github-actions Bot removed the feature New feature or request label Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-8665 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-8665 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-8665 Finished ✅ Results ✅
ghcr.io/flagsmith/flagsmith:pr-8665 Finished ✅ Results ✅
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8665 Finished ✅ Results ✅
ghcr.io/flagsmith/flagsmith-frontend:pr-8665 Finished ✅ Results ✅

@github-actions github-actions Bot added the feature New feature or request label Oct 11, 2026
@gagantrivedi
gagantrivedi removed request for a team and emyller October 11, 2026 03:04
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #21515 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  35.2 seconds
commit  65567a7
info  🔄 Run: #21515 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-16 — run #21515 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  56 seconds
commit  65567a7
info  🔄 Run: #21515 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #21515 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  36.3 seconds
commit  65567a7
info  🔄 Run: #21515 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #21515 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  31.7 seconds
commit  65567a7
info  🔄 Run: #21515 (attempt 1)

@github-actions

Copy link
Copy Markdown
Contributor

Visual Regression

20 screenshots compared. See report for details.
View full report

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants