Skip to content

Add UpdateAt to items and users - #1392

Merged
zhenghaoz merged 10 commits into
gorse-io:masterfrom
zhangzhenghao:feat/item-update-at
Oct 2, 2026
Merged

zhenghaoz merged 10 commits into
gorse-io:masterfrom
zhangzhenghao:feat/item-update-at

Conversation

@zhangzhenghao

@zhangzhenghao zhangzhenghao commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add internal, storage-owned UpdateAt metadata to items and users, separate from business Timestamp.
  • Automatically assign current UTC write times on inserts/upserts and non-empty partial updates across SQL and MongoDB; feedback auto-creation assigns write timestamps using each backend's existing insertion behavior.
  • Extend SQL schema migrations, reads, and internal protobuf/proxy transport.
  • Hide the field from mapstructure and JSON with mapstructure:"-" and json:"-". REST responses and exports retain their existing shapes; master/rest.go is unchanged.
  • Adjust existing storage assertions to verify nonzero update times, then clear them before comparing business fields. Existing user/item tests also verify that update times increase after upserts and partial updates using testify Greater.

Verification

  • Regenerated protocol/protocol.pb.go from the schema using protoc 6.33.4 and protoc-gen-go 1.36.10 to fix malformed update_at descriptors that caused protobuf dependency resolution to panic with index out of range [-1] during dumps and RPCs.
  • Passed go test ./cmd/gorse-cli ./master ./server ./worker ./storage/blob ./storage/data -count=1 -timeout=5m, including dump/restore and RPC tests.
  • Passed go test ./storage/data -run '^(TestSQLite|TestProxy)$' -count=1 -timeout=3m after restoring the existing ClickHouse query behavior. Verified that the PR introduces no FINAL changes and latest-item reads use the existing latest-items table.
  • Passed go test ./storage/data -run '^(TestSQLite|TestProxy)/(TestUsers|TestItems)$' -count=1 -timeout=3m with the update-time comparisons and the restored ClickHouse write flow.
  • Go formatting and git diff --check completed. External database suites remain unverified locally; CI must validate those backends.

Migration semantics

Existing SQL records receive the Unix epoch default because their historical write time is unknown. Existing MongoDB documents without this field retain the zero value until updated. Normal writes override caller-supplied UpdateAt; empty patches do not refresh it.

@zhenghaoz zhenghaoz changed the title feat(data): track item and user update times Add UpdateAt to items and users Oct 2, 2026
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.77419% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.24%. Comparing base (a4fd98a) to head (735637c).

Files with missing lines Patch % Lines
storage/data/mongodb.go 80.00% 2 Missing ⚠️
storage/data/proxy.go 97.43% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1392      +/-   ##
==========================================
+ Coverage   79.03%   79.24%   +0.21%     
==========================================
  Files          92       92              
  Lines       16406    16447      +41     
==========================================
+ Hits        12966    13033      +67     
+ Misses       3440     3414      -26     

☔ 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.

@zhenghaoz
zhenghaoz merged commit 2abea7e into gorse-io:master Oct 2, 2026
13 checks passed
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.

2 participants