feat: daily reset for syndicate standing #582
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "daily-reset"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Walkthrough
This pull request introduces several interconnected changes across multiple files to enhance account and inventory management functionality. The primary modifications include:
In the login service and types, a new
LastLoginDay
field is added to track the most recent login date for an account.The
inventoryController
is updated to implement a daily reset mechanism. When a user logs in, the controller now checks if the current login day differs from the last login day, and if so, resets certain daily affiliation values to 16000.The
getAccountIdForRequest
function is refactored togetAccountForRequest
in the login service, now returning the entire account object instead of just the account ID.Type definitions are updated across multiple files, including changes to
IInventoryDatabase
andIInventoryResponse
interfaces, modifying how certain properties are typed (e.g., usingTypes.ObjectId
instead of previous type definitions).A new
DailyAffiliationHex
property is introduced in the inventory model and types, expanding the tracking capabilities for daily affiliations.These changes appear to be part of a broader effort to improve account tracking, daily reset mechanics, and type safety in the application's data models.
Sequence Diagram
Possibly related PRs
inventoryController.ts
related toinventoryJSON
handling, which shares a similar scope of changes to the current pull request's modifications to the inventory controller.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?
❤️ Share
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
I pushed a fix in commit <commit_id>, please review it.
Generate unit testing code for this file.
Open a follow-up GitHub issue for this discussion.
@coderabbitai
in a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.
@coderabbitai modularize this function.
@coderabbitai
in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
@coderabbitai read src/utils.ts and generate unit testing code.
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
@coderabbitai help me debug CodeRabbit configuration file.
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 using PR comments)
@coderabbitai pause
to pause the reviews on a PR.@coderabbitai resume
to resume the paused reviews.@coderabbitai review
to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full review
to do a full review from scratch and review all the files again.@coderabbitai summary
to regenerate the summary of the PR.@coderabbitai resolve
resolve all the CodeRabbit review comments.@coderabbitai configuration
to show the current CodeRabbit configuration for the repository.@coderabbitai help
to get help.Other keywords and placeholders
@coderabbitai ignore
anywhere in the PR description to prevent this PR from being reviewed.@coderabbitai summary
to generate the high-level summary at a specific location in the PR description.@coderabbitai
anywhere in the PR title to generate the title automatically.Documentation and Community
Actionable comments posted: 2
🔭 Outside diff range comments (1)
🧹 Nitpick comments (2)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
259bfa1362
and17f511359c
.📒 Files selected for processing (6)
src/controllers/api/inventoryController.ts
(3 hunks)src/models/inventoryModels/inventoryModel.ts
(1 hunks)src/models/loginModel.ts
(1 hunks)src/services/loginService.ts
(2 hunks)src/types/inventoryTypes/inventoryTypes.ts
(1 hunks)src/types/loginTypes.ts
(1 hunks)🔇 Additional comments (5)
src/services/loginService.ts (1)
67-68
: LGTM! Clean implementation of getAccountIdForRequest.The function properly reuses getAccountForRequest and extracts the ID.
src/controllers/api/inventoryController.ts (2)
15-17
: LGTM: Account retrieval change is well-aligned with requirements.The switch from
getAccountIdForRequest
togetAccountForRequest
properly supports the daily reset functionality by providing access to the account's LastLoginDay field.23-26
: LGTM: Inventory query properly uses account ObjectId.The query correctly uses
account._id.toString()
to find the inventory document.src/types/inventoryTypes/inventoryTypes.ts (1)
278-278
: LGTM: Type definition is consistent with existing pattern.The
DailyAffiliationHex
property follows the same pattern as other daily affiliation properties in the interface.src/models/inventoryModels/inventoryModel.ts (1)
638-638
: LGTM: Schema definition matches existing pattern.The
DailyAffiliationHex
field is correctly defined as a Number type, consistent with other daily affiliation fields in the schema.@ -36,2 +36,3 @@
Nonce: { type: Number, default: 0 }
Nonce: { type: Number, default: 0 },
LastLoginDay: { type: Number }
},
🛠️ Refactor suggestion
Consider adding a default value for LastLoginDay.
While the schema addition matches the interface, consider setting a default value for new accounts to ensure consistency.
Apply this change:
This sets the default to the current day number (days since epoch) when creating new accounts.
📝 Committable suggestion
@ -32,6 +32,7 @@ export interface IDatabaseAccount {
ConsentNeeded: boolean;
TrackedSettings: string[];
Nonce: number;
LastLoginDay?: number;
💡 Codebase verification
Potential backward compatibility issue found
The field is marked as optional in the interface (
LastLoginDay?: number
), but the MongoDB schema inloginModel.ts
defines it as a required field without a default value (LastLoginDay: { type: Number }
). This mismatch could cause runtime errors for existing accounts that don't have this field set.src/models/loginModel.ts
: Add a default value to theLastLoginDay
schema field to maintain backward compatibilitysrc/controllers/api/inventoryController.ts
: Add null check before comparingaccount.LastLoginDay
withtoday
🔗 Analysis chain
LGTM! Verify backward compatibility.
The optional
LastLoginDay
field is properly typed and maintains backward compatibility with existing accounts.Let's verify there are no required usages of this optional field:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 54
Script:
Length of output: 981
@ -32,6 +32,7 @@ export interface IDatabaseAccount {
ConsentNeeded: boolean;
TrackedSettings: string[];
Nonce: number;
LastLoginDay?: number;
Non-issue.
@ -36,2 +36,3 @@
Nonce: { type: Number, default: 0 }
Nonce: { type: Number, default: 0 },
LastLoginDay: { type: Number }
},
Fuck off
@ -32,6 +32,7 @@ export interface IDatabaseAccount {
ConsentNeeded: boolean;
TrackedSettings: string[];
Nonce: number;
LastLoginDay?: number;
@Sainan, understood. Acknowledged your decision; no further action will be taken on this matter.
@ -36,2 +36,3 @@
Nonce: { type: Number, default: 0 }
Nonce: { type: Number, default: 0 },
LastLoginDay: { type: Number }
},
@Sainan I’m sorry to see you upset. Let me know if there’s anything I can do to help.
(_ _)( ; ; )
Actionable comments posted: 0
🧹 Nitpick comments (1)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
17f511359c
and36fe9db781
.📒 Files selected for processing (1)
src/controllers/api/loginController.ts
(2 hunks)🔇 Additional comments (2)
src/controllers/api/loginController.ts (2)
39-39
: Verify LastLoginDay management across the codebaseThe addition of
LastLoginDay
to the excluded fields in the response appears to be part of the daily reset feature for syndicate standing. However, we should verify:Let's check the related implementations:
Also applies to: 75-75
✅ Verification successful
Based on the results, I can now generate the final response since we have clear evidence of how
LastLoginDay
is being used in the codebase.Excluding LastLoginDay from response is correct and consistent with its usage
The exclusion of
LastLoginDay
from the login response is correct as it's an internal field used for daily reset logic:inventoryController.ts
, it's used to manage daily resets for affiliation (syndicate standing)loginController.ts
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1457
39-39
: Ensure consistent response structure for new accountsThe destructuring pattern
{ email, password, LastLoginDay, ...databaseAccount }
assumesLastLoginDay
exists in new accounts. Verify thatcreateAccount
properly initializes this field.✅ Verification successful
LastLoginDay is optional and safely handled in the code
The destructuring pattern is safe because:
LastLoginDay
is defined as an optional field in the account interface (LastLoginDay?: number
)🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 124
Script:
Length of output: 2812
Script:
Length of output: 1990
Script:
Length of output: 3224