chore: clean up code by removing trailing whitespace and ensuring consistent formatting across various files = prettier
This commit is contained in:
@@ -10,7 +10,7 @@ export const transactionService = {
|
||||
async createMany(transactions: Transaction[]): Promise<CreateManyResult> {
|
||||
// Get unique account IDs
|
||||
const accountIds = [...new Set(transactions.map((t) => t.accountId))];
|
||||
|
||||
|
||||
// Check for existing transactions by fitId
|
||||
const existingByFitId = await prisma.transaction.findMany({
|
||||
where: {
|
||||
@@ -43,11 +43,11 @@ export const transactionService = {
|
||||
const existingFitIdSet = new Set(
|
||||
existingByFitId.map((t) => `${t.accountId}-${t.fitId}`),
|
||||
);
|
||||
|
||||
|
||||
// Create set for duplicates by amount + date + description
|
||||
const existingCriteriaSet = new Set(
|
||||
allExistingTransactions.map((t) =>
|
||||
`${t.accountId}-${t.date}-${t.amount}-${t.description}`
|
||||
allExistingTransactions.map(
|
||||
(t) => `${t.accountId}-${t.date}-${t.amount}-${t.description}`,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -55,8 +55,10 @@ export const transactionService = {
|
||||
const newTransactions = transactions.filter((t) => {
|
||||
const fitIdKey = `${t.accountId}-${t.fitId}`;
|
||||
const criteriaKey = `${t.accountId}-${t.date}-${t.amount}-${t.description}`;
|
||||
|
||||
return !existingFitIdSet.has(fitIdKey) && !existingCriteriaSet.has(criteriaKey);
|
||||
|
||||
return (
|
||||
!existingFitIdSet.has(fitIdKey) && !existingCriteriaSet.has(criteriaKey)
|
||||
);
|
||||
});
|
||||
|
||||
if (newTransactions.length === 0) {
|
||||
@@ -122,7 +124,10 @@ export const transactionService = {
|
||||
});
|
||||
},
|
||||
|
||||
async deduplicate(): Promise<{ deletedCount: number; duplicatesFound: number }> {
|
||||
async deduplicate(): Promise<{
|
||||
deletedCount: number;
|
||||
duplicatesFound: number;
|
||||
}> {
|
||||
// Get all transactions grouped by account
|
||||
const allTransactions = await prisma.transaction.findMany({
|
||||
orderBy: [
|
||||
@@ -155,7 +160,7 @@ export const transactionService = {
|
||||
for (const [accountId, transactions] of transactionsByAccount.entries()) {
|
||||
for (const transaction of transactions) {
|
||||
const key = `${accountId}-${transaction.date}-${transaction.amount}-${transaction.description}`;
|
||||
|
||||
|
||||
if (seenKeys.has(key)) {
|
||||
// This is a duplicate, mark for deletion
|
||||
duplicatesToDelete.push(transaction.id);
|
||||
@@ -181,5 +186,3 @@ export const transactionService = {
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user