-
-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set updated_at
with created_at
when creating Document
#977
Conversation
WalkthroughThe recent changes involve adding an Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- server/backend/database/memory/database.go (1 hunks)
- server/backend/database/mongo/client.go (1 hunks)
- server/backend/database/testcases/testcases.go (3 hunks)
Additional comments not posted (5)
server/backend/database/memory/database.go (1)
749-749
: Ensure correct initialization ofUpdatedAt
field.The addition of the
UpdatedAt
field is correctly implemented to match theCreatedAt
timestamp when a new document is created. This aligns with the PR's objective to maintain consistency between these timestamps at creation.server/backend/database/mongo/client.go (1)
742-744
: Proper handling ofUpdatedAt
during document creation.The implementation correctly sets the
UpdatedAt
field when a new document is created, ensuring that it reflects the current time. This change is crucial for maintaining the accuracy of document metadata.server/backend/database/testcases/testcases.go (3)
951-953
: Ensure proper initialization of timestamps and ownership.The changes correctly assert that the
owner
matches the client's ID,updated_at
is not a default value, andupdated_at
matchescreated_at
upon document creation. These checks align with the PR objectives and address the issue effectively.
963-963
: Verify presence update does not alterupdated_at
.The test ensures that updating only the presence of a document does not change the
updated_at
timestamp, which is expected behavior. This is a good practice to verify that unnecessary updates toupdated_at
are not made.
974-974
: Check thatupdated_at
changes with document modifications.This test verifies that
updated_at
is modified when the document's content is changed, which is crucial for tracking modifications accurately. It's important to ensure thatupdated_at
reflects the most recent change.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #977 +/- ##
=======================================
Coverage 51.06% 51.07%
=======================================
Files 73 73
Lines 10782 10784 +2
=======================================
+ Hits 5506 5508 +2
Misses 4725 4725
Partials 551 551 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
updated_at
with created_at
when creating new Document
updated_at
with created_at
when creating Document
What this PR does / why we need it:
Which issue(s) this PR fixes:
This PR ensures that when a new
Document
is created and attached, theupdated_at
field is initialized with thecreated_at
timestamp.Before the commit b494fa2d, the
updated_at
field was correctly set during the attachment process through apushpull
operation that included presence. However, after this commit, theupdated_at
field is no longer updated when the document is attached, leading to inconsistencies.Fixes #968
Special notes for your reviewer:
The underlying issue stems from the
FindDocInfoByKeyAndOwner
function, which returned aDocInfo
object without setting the "owner", "server_seq", "created_at", and "updated_at" fields, leading to zero values being assigned. While this functionality is acceptable within the specific context where onlyproject_id
andid
are required, it creates issues when theAttachDocument
function relies on these values. It currently works around this issue sinceserver_seq
has a zero value of 0.However, I believe we should return
DocInfo
with the updated "owner", "server_seq", "created_at", "updated_at" fields to maintain consistency and improve clarity.Does this PR introduce a user-facing change?:
Additional documentation:
Checklist:
Summary by CodeRabbit
New Features
UpdatedAt
field for improved tracking of document update times.Bug Fixes
Documentation