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
LastLoginDayfield is added to track the most recent login date for an account.The
inventoryControlleris 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
getAccountIdForRequestfunction is refactored togetAccountForRequestin 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
IInventoryDatabaseandIInventoryResponseinterfaces, modifying how certain properties are typed (e.g., usingTypes.ObjectIdinstead of previous type definitions).A new
DailyAffiliationHexproperty 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.tsrelated toinventoryJSONhandling, 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.@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.Other keywords and placeholders
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed.@coderabbitai summaryto generate the high-level summary at a specific location in the PR description.@coderabbitaianywhere 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
259bfa1362and17f511359c.📒 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
getAccountIdForRequesttogetAccountForRequestproperly 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
DailyAffiliationHexproperty 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
DailyAffiliationHexfield 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.tsdefines 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 theLastLoginDayschema field to maintain backward compatibilitysrc/controllers/api/inventoryController.ts: Add null check before comparingaccount.LastLoginDaywithtoday🔗 Analysis chain
LGTM! Verify backward compatibility.
The optional
LastLoginDayfield 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
17f511359cand36fe9db781.📒 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
LastLoginDayto 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
LastLoginDayis being used in the codebase.Excluding LastLoginDay from response is correct and consistent with its usage
The exclusion of
LastLoginDayfrom 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 }assumesLastLoginDayexists in new accounts. Verify thatcreateAccountproperly initializes this field.✅ Verification successful
LastLoginDay is optional and safely handled in the code
The destructuring pattern is safe because:
LastLoginDayis 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