fix: correctly add kubrow eggs to inventory #875

Merged
Sainan merged 1 commits from get-egg into main 2025-01-31 08:02:46 -08:00
Owner

Fixes #874

Fixes #874
coderabbitai[bot] commented 2025-01-31 01:55:42 -08:00 (Migrated from github.com)
Author
Owner

Walkthrough

The pull request introduces comprehensive changes to the inventory management system, specifically focusing on the handling of Kubrow pet eggs. The modifications span across three files: inventoryModel.ts, inventoryService.ts, and inventoryTypes.ts. The changes include creating new interfaces for Kubrow pet eggs, defining a new schema with specific transformation methods, and updating the inventory service logic to correctly process and store Kubrow pet eggs. The implementation ensures that Kubrow eggs are stored with specific attributes like ItemType, ExpirationDate, and a generated ItemId, providing a more structured approach to managing these items in the inventory system.

Assessment against linked issues

Objective Addressed Explanation
Store Kubrow Eggs in KubrowPetEggs array
Include ItemType for Kubrow Eggs
Include ExpirationDate for Kubrow Eggs
Generate ItemId for Kubrow Eggs

The changes comprehensively address the requirements specified in issue #874, implementing a robust mechanism for acquiring and storing Kubrow pet eggs with the exact structure outlined in the issue description. The implementation includes schema definition, type interfaces, and service logic to ensure correct handling of Kubrow eggs in the inventory system.

Finishing Touches
  • 📝 Generate Docstrings (Beta)

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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • 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.
  • Files and specific lines of code (under the "Files changed" tab): Tag @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.
  • PR comments: Tag @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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.
<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- walkthrough_start --> ## Walkthrough The pull request introduces comprehensive changes to the inventory management system, specifically focusing on the handling of Kubrow pet eggs. The modifications span across three files: `inventoryModel.ts`, `inventoryService.ts`, and `inventoryTypes.ts`. The changes include creating new interfaces for Kubrow pet eggs, defining a new schema with specific transformation methods, and updating the inventory service logic to correctly process and store Kubrow pet eggs. The implementation ensures that Kubrow eggs are stored with specific attributes like ItemType, ExpirationDate, and a generated ItemId, providing a more structured approach to managing these items in the inventory system. ## Assessment against linked issues | Objective | Addressed | Explanation | |-----------|-----------|-------------| | Store Kubrow Eggs in KubrowPetEggs array | ✅ | | | Include ItemType for Kubrow Eggs | ✅ | | | Include ExpirationDate for Kubrow Eggs | ✅ | | | Generate ItemId for Kubrow Eggs | ✅ | | The changes comprehensively address the requirements specified in issue #874, implementing a robust mechanism for acquiring and storing Kubrow pet eggs with the exact structure outlined in the issue description. The implementation includes schema definition, type interfaces, and service logic to ensure correct handling of Kubrow eggs in the inventory system. <!-- walkthrough_end --> <!-- internal state start --> <!-- FAHghAtBAEAqAWBLAztF0CGA7TBXALgPYQDmAplmQE4b5kAm0AxoQLasX4Bc0ADldEIAjAFZkm+RADcyqIQE9mhetQxChifADoMiaFAB8wY+CjGAxOegAFAErQAyrnYYq84wjJ9cAGx/QqMgBHXFl8aEl8HwZoACIAM0QADx4WKkCJH0UMekYAa1whKkIAd2gyEhJUIjQsGSwiN1joEoxUZELWTTpGBQj4L1xkakddLGxMLEZ0RBUGxESYtugsZyERgA4AdgBWLTgBvipEVldFXlwqXkJhwXj+9Ds0asJMXMDkVAmUDq9A+OoFCYS1Q5m2ABZ9p5oCpkExjrxJIQcIgpogmLRZP1aP0vEx4NhyKhTipag9UBc/AFgqFkOFXF5UXQpjEahQOoFseECkVSuVKl9OWkMlFsrlWa98IdUfVGopkPI6WRWC1NEgcFKvBheLwfOjaIhkftjAAxQgCeKXTUCFT4XQ+ZAAGlx3ipgRCYWYE3WmCYwM+S3Cmug8UIflKqJI0AAqrYADI8ADa8Hw+F4yC4AHpMyQ1YUtCxWJnkLwMMCsKiRG1qDIqJmHKXgQA5SsYBw16iZyk+TPbHYAXQAFCm0xns7mpfnC8XGxRW8MqLX67OW1gq+3F53u73dgBKLTGQwmSAwCiMQj3DAEYjkSg0HpKdicHj8QSicSSGRyRQsFQ0dSaDoehHqYMAIDMXw4FeRCkBQqgPoWHANDwNBlB0LhuNAfS/qoAHaLo+gQEYx5mMAyBUEwmasMoZAOpmMqcOa8gALI0XRDENExrEqD4Wj4BmwCxEJwCWNAACCACSsF3pijDoacmEXswBJYESHiHPQCz3EyxT0Lg/orGQZRMtQ8Rlli2ByfiyrLIEPiyRErwANKFMUZS8GQ4QVFUZLBgABhxcrcbRfHIH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LALIUJIlPYKlNJLtDV2hQBKVNpJpOpTpPCgZNlSZNwIII8L8h1OuKRINL5MWOkIFDNLWOxW4K2NGQ+OjxJK4PUOdMpPdLlGBPOOWVVMZKhLqyWJajjJ1PaVtOpH5hMMiSGJGkCM+O6WjMsM6nJRdJNUVJbOVJiPBOFlFlU3J3zIjJIEDPuRLKCMVxyirPCATP4PrJV0dOrTlKpPbLbLdI7PpK7MQ3JwDnCBL1RAYHhOdwt2IlAj4XPEvGvHd3FUYEQmfACAwDQi9ylWwhon/A0HwmAiIlABPEfC6HwFIWQHxkCFFiMgYHxjGmrKPA/KgGgAADZwQAAGLYeIZNddddEbAATjIGTSgpG1gp2FgqYC2AwCgvQpUC2HBCYGTRgRG3oHXQwB2HiCEFQqgsIkPM/MQk0F/P/IQyAvoHxjPGYqAA= --> <!-- internal state end --> <!-- finishing_touch_checkbox_start --> <details> <summary>✨ Finishing Touches</summary> - [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings (Beta) </details> <!-- finishing_touch_checkbox_end --> <!-- tips_start --> --- 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? <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <details> <summary>🪧 Tips</summary> ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `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.` - Files and specific lines of code (under the "Files changed" tab): Tag `@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.` - PR comments: Tag `@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 generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR. ([Beta](https://docs.coderabbit.ai/early-access#beta)) - `@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 - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### Documentation and Community - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements. </details> <!-- tips_end -->
coderabbitai[bot] (Migrated from github.com) reviewed 2025-01-31 01:59:49 -08:00
coderabbitai[bot] (Migrated from github.com) left a comment
Author
Owner

Actionable comments posted: 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 cf196430b7 and 6407f12239.

📒 Files selected for processing (3)
  • src/models/inventoryModels/inventoryModel.ts (3 hunks)
  • src/services/inventoryService.ts (4 hunks)
  • src/types/inventoryTypes/inventoryTypes.ts (4 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/models/inventoryModels/inventoryModel.ts

[error] 401-401: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 402-402: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🔇 Additional comments (6)
src/types/inventoryTypes/inventoryTypes.ts (2)

620-623: LGTM!

The database interface is correctly defined with minimal required fields.


614-618: Consider adding validation for ExpirationDate.

The ExpirationDate field in IKubrowPetEggClient is hardcoded to 7 days ahead at 0 UTC according to the comment, but there's no validation to ensure this constraint.

Consider adding a validation function or using a library like class-validator to enforce this constraint:

import { IsDate, MinDate } from 'class-validator';

export interface IKubrowPetEggClient {
    ItemType: string;
    @IsDate()
    @MinDate(() => {
        const date = new Date();
        date.setDate(date.getDate() + 7);
        date.setUTCHours(0, 0, 0, 0);
        return date;
    })
    ExpirationDate: IMongoDate;
    ItemId: IOid;
}
src/models/inventoryModels/inventoryModel.ts (2)

386-391: LGTM!

The schema definition is correct and matches the database interface.


938-938: LGTM!

The schema is correctly integrated into the inventory model.

src/services/inventoryService.ts (2)

23-25: LGTM!

The imports are correctly added and organized.


215-227: LGTM!

The MiscItems handling logic is correctly implemented.

**Actionable comments posted: 2** <details> <summary>📜 Review details</summary> **Configuration used: .coderabbit.yaml** **Review profile: CHILL** **Plan: Pro** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between cf196430b71bbecbca075e1bb92eb19001b2a5e7 and 6407f12239e163050c7a69ede74c1ba3d2a5fb96. </details> <details> <summary>📒 Files selected for processing (3)</summary> * `src/models/inventoryModels/inventoryModel.ts` (3 hunks) * `src/services/inventoryService.ts` (4 hunks) * `src/types/inventoryTypes/inventoryTypes.ts` (4 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🪛 Biome (1.9.4)</summary> <details> <summary>src/models/inventoryModels/inventoryModel.ts</summary> [error] 401-401: Avoid the delete operator which can impact performance. Unsafe fix: Use an undefined assignment instead. (lint/performance/noDelete) --- [error] 402-402: Avoid the delete operator which can impact performance. Unsafe fix: Use an undefined assignment instead. (lint/performance/noDelete) </details> </details> </details> <details> <summary>🔇 Additional comments (6)</summary><blockquote> <details> <summary>src/types/inventoryTypes/inventoryTypes.ts (2)</summary> `620-623`: **LGTM!** The database interface is correctly defined with minimal required fields. --- `614-618`: **Consider adding validation for ExpirationDate.** The `ExpirationDate` field in `IKubrowPetEggClient` is hardcoded to 7 days ahead at 0 UTC according to the comment, but there's no validation to ensure this constraint. Consider adding a validation function or using a library like `class-validator` to enforce this constraint: ```typescript import { IsDate, MinDate } from 'class-validator'; export interface IKubrowPetEggClient { ItemType: string; @IsDate() @MinDate(() => { const date = new Date(); date.setDate(date.getDate() + 7); date.setUTCHours(0, 0, 0, 0); return date; }) ExpirationDate: IMongoDate; ItemId: IOid; } ``` </details> <details> <summary>src/models/inventoryModels/inventoryModel.ts (2)</summary> `386-391`: **LGTM!** The schema definition is correct and matches the database interface. --- `938-938`: **LGTM!** The schema is correctly integrated into the inventory model. </details> <details> <summary>src/services/inventoryService.ts (2)</summary> `23-25`: **LGTM!** The imports are correctly added and organized. --- `215-227`: **LGTM!** The MiscItems handling logic is correctly implemented. </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
coderabbitai[bot] (Migrated from github.com) commented 2025-01-31 01:59:48 -08:00
Author
Owner

⚠️ Potential issue

Avoid hardcoding the expiration timestamp.

The expiration date is hardcoded to "2000000000000" which is Wed May 18 2033. This could cause issues in the future.

Consider calculating the expiration date dynamically:

-        client.ExpirationDate = { $date: { $numberLong: "2000000000000" } };
+        const expiryDate = new Date();
+        expiryDate.setDate(expiryDate.getDate() + 7);
+        expiryDate.setUTCHours(0, 0, 0, 0);
+        client.ExpirationDate = { $date: { $numberLong: expiryDate.getTime().toString() } };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

kubrowPetEggSchema.set("toJSON", {
    virtuals: true,
    transform(_document, obj) {
        const client = obj as IKubrowPetEggClient;
        const db = obj as IKubrowPetEggDatabase;

        const expiryDate = new Date();
        expiryDate.setDate(expiryDate.getDate() + 7);
        expiryDate.setUTCHours(0, 0, 0, 0);
        client.ExpirationDate = { $date: { $numberLong: expiryDate.getTime().toString() } };
        client.ItemId = toOid(db._id);

        delete obj._id;
        delete obj.__v;
    }
});
🧰 Tools
🪛 Biome (1.9.4)

[error] 401-401: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 402-402: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

_:warning: Potential issue_ **Avoid hardcoding the expiration timestamp.** The expiration date is hardcoded to "2000000000000" which is Wed May 18 2033. This could cause issues in the future. Consider calculating the expiration date dynamically: ```diff - client.ExpirationDate = { $date: { $numberLong: "2000000000000" } }; + const expiryDate = new Date(); + expiryDate.setDate(expiryDate.getDate() + 7); + expiryDate.setUTCHours(0, 0, 0, 0); + client.ExpirationDate = { $date: { $numberLong: expiryDate.getTime().toString() } }; ``` <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion kubrowPetEggSchema.set("toJSON", { virtuals: true, transform(_document, obj) { const client = obj as IKubrowPetEggClient; const db = obj as IKubrowPetEggDatabase; const expiryDate = new Date(); expiryDate.setDate(expiryDate.getDate() + 7); expiryDate.setUTCHours(0, 0, 0, 0); client.ExpirationDate = { $date: { $numberLong: expiryDate.getTime().toString() } }; client.ItemId = toOid(db._id); delete obj._id; delete obj.__v; } }); ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>🪛 Biome (1.9.4)</summary> [error] 401-401: Avoid the delete operator which can impact performance. Unsafe fix: Use an undefined assignment instead. (lint/performance/noDelete) --- [error] 402-402: Avoid the delete operator which can impact performance. Unsafe fix: Use an undefined assignment instead. (lint/performance/noDelete) </details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] (Migrated from github.com) commented 2025-01-31 01:59:49 -08:00
Author
Owner

⚠️ Potential issue

Fix hardcoded expiration date and item type.

Two issues in the KubrowPetEggs handling:

  1. The expiration date is hardcoded to "2000000000000"
  2. The item type is hardcoded instead of using the provided typeName parameter

Apply this fix:

        } else if (ExportResources[typeName].productCategory == "KubrowPetEggs") {
            const changes: IKubrowPetEggClient[] = [];
            for (let i = 0; i != quantity; ++i) {
                const egg: IKubrowPetEggDatabase = {
-                    ItemType: "/Lotus/Types/Game/KubrowPet/Eggs/KubrowEgg",
+                    ItemType: typeName,
                    _id: new Types.ObjectId()
                };
                inventory.KubrowPetEggs ??= [];
                inventory.KubrowPetEggs.push(egg);
+                const expiryDate = new Date();
+                expiryDate.setDate(expiryDate.getDate() + 7);
+                expiryDate.setUTCHours(0, 0, 0, 0);
                changes.push({
                    ItemType: egg.ItemType,
-                    ExpirationDate: { $date: { $numberLong: "2000000000000" } },
+                    ExpirationDate: { $date: { $numberLong: expiryDate.getTime().toString() } },
                    ItemId: toOid(egg._id)
                });
            }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

        } else if (ExportResources[typeName].productCategory == "KubrowPetEggs") {
            const changes: IKubrowPetEggClient[] = [];
            for (let i = 0; i != quantity; ++i) {
                const egg: IKubrowPetEggDatabase = {
                    ItemType: typeName,
                    _id: new Types.ObjectId()
                };
                inventory.KubrowPetEggs ??= [];
                inventory.KubrowPetEggs.push(egg);
                const expiryDate = new Date();
                expiryDate.setDate(expiryDate.getDate() + 7);
                expiryDate.setUTCHours(0, 0, 0, 0);
                changes.push({
                    ItemType: egg.ItemType,
                    ExpirationDate: { $date: { $numberLong: expiryDate.getTime().toString() } },
                    ItemId: toOid(egg._id)
                });
            }
_:warning: Potential issue_ **Fix hardcoded expiration date and item type.** Two issues in the KubrowPetEggs handling: 1. The expiration date is hardcoded to "2000000000000" 2. The item type is hardcoded instead of using the provided typeName parameter Apply this fix: ```diff } else if (ExportResources[typeName].productCategory == "KubrowPetEggs") { const changes: IKubrowPetEggClient[] = []; for (let i = 0; i != quantity; ++i) { const egg: IKubrowPetEggDatabase = { - ItemType: "/Lotus/Types/Game/KubrowPet/Eggs/KubrowEgg", + ItemType: typeName, _id: new Types.ObjectId() }; inventory.KubrowPetEggs ??= []; inventory.KubrowPetEggs.push(egg); + const expiryDate = new Date(); + expiryDate.setDate(expiryDate.getDate() + 7); + expiryDate.setUTCHours(0, 0, 0, 0); changes.push({ ItemType: egg.ItemType, - ExpirationDate: { $date: { $numberLong: "2000000000000" } }, + ExpirationDate: { $date: { $numberLong: expiryDate.getTime().toString() } }, ItemId: toOid(egg._id) }); } ``` <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion } else if (ExportResources[typeName].productCategory == "KubrowPetEggs") { const changes: IKubrowPetEggClient[] = []; for (let i = 0; i != quantity; ++i) { const egg: IKubrowPetEggDatabase = { ItemType: typeName, _id: new Types.ObjectId() }; inventory.KubrowPetEggs ??= []; inventory.KubrowPetEggs.push(egg); const expiryDate = new Date(); expiryDate.setDate(expiryDate.getDate() + 7); expiryDate.setUTCHours(0, 0, 0, 0); changes.push({ ItemType: egg.ItemType, ExpirationDate: { $date: { $numberLong: expiryDate.getTime().toString() } }, ItemId: toOid(egg._id) }); } ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
Sign in to join this conversation.
No description provided.