feat: add missing data checker (works in conjunction with archiver mi…#87
feat: add missing data checker (works in conjunction with archiver mi…#87
Conversation
…ssing data script)
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
| const receiptRecord = Receipt.queryReceiptByReceiptId(receipt.id) | ||
| if (!receiptRecord) { | ||
| console.log(`Missing receipt record for receipt ${receipt.id}`) | ||
| nonPatchedData.receipts.push(receipt) | ||
| } else { | ||
| console.log(`Receipt record for receipt ${receipt.id} exists`) | ||
| } |
There was a problem hiding this comment.
Suggestion: The call to Receipt.queryReceiptByReceiptId is likely asynchronous, but it is not awaited. This can cause receiptRecord to be a Promise, leading to incorrect logic and missed missing receipts. [possible issue, importance: 8]
| const receiptRecord = Receipt.queryReceiptByReceiptId(receipt.id) | |
| if (!receiptRecord) { | |
| console.log(`Missing receipt record for receipt ${receipt.id}`) | |
| nonPatchedData.receipts.push(receipt) | |
| } else { | |
| console.log(`Receipt record for receipt ${receipt.id} exists`) | |
| } | |
| const receiptRecord = await Receipt.queryReceiptByReceiptId(receipt.id) | |
| if (!receiptRecord) { | |
| console.log(`Missing receipt record for receipt ${receipt.id}`) | |
| nonPatchedData.receipts.push(receipt) | |
| } else { | |
| console.log(`Receipt record for receipt ${receipt.id} exists`) | |
| } |
| const accountRecord = Account.queryAccountByAccountId(account.id) | ||
| if (!accountRecord) { | ||
| console.log(`Missing account record for account ${account.id}`) | ||
| nonPatchedData.accounts.push(account) | ||
| } else { | ||
| console.log(`Account record for account ${account.id} exists`) | ||
| } |
There was a problem hiding this comment.
Suggestion: The call to Account.queryAccountByAccountId is likely asynchronous, but it is not awaited. This may cause logic errors and incorrect detection of missing accounts. [possible issue, importance: 8]
| const accountRecord = Account.queryAccountByAccountId(account.id) | |
| if (!accountRecord) { | |
| console.log(`Missing account record for account ${account.id}`) | |
| nonPatchedData.accounts.push(account) | |
| } else { | |
| console.log(`Account record for account ${account.id} exists`) | |
| } | |
| const accountRecord = await Account.queryAccountByAccountId(account.id) | |
| if (!accountRecord) { | |
| console.log(`Missing account record for account ${account.id}`) | |
| nonPatchedData.accounts.push(account) | |
| } else { | |
| console.log(`Account record for account ${account.id} exists`) | |
| } |
| Storage.closeDatabase() | ||
| console.log('Database closed') | ||
| console.log('Script completed successfully') | ||
| process.exit(0) |
There was a problem hiding this comment.
Suggestion: Storage.closeDatabase() is likely asynchronous, but it is not awaited. Not awaiting it may cause the process to exit before the database is properly closed, risking data corruption or resource leaks. [possible issue, importance: 7]
| Storage.closeDatabase() | |
| console.log('Database closed') | |
| console.log('Script completed successfully') | |
| process.exit(0) | |
| await Storage.closeDatabase() | |
| console.log('Database closed') | |
| console.log('Script completed successfully') | |
| process.exit(0) |
User description
…ssing data script)
PR Type
Enhancement
Description
Introduces a script to check for missing data in the database
Reads a JSON file with expected data and verifies existence in storage
Outputs a JSON file listing still-missing records
Supports cycles, receipts, accounts, and transactions tables
Changes walkthrough 📝
checkMissingData.ts
Add script to check and report missing database recordsscripts/checkMissingData.ts