️ Return early if no transactions were fetched

This commit is contained in:
Martin Berg Alstad 2025-02-16 18:00:25 +01:00
parent a2c6c55430
commit a0cefcdfa1
Signed by: martials
GPG Key ID: A3824877B269F2E2

View File

@ -15,7 +15,6 @@ import { Sparebank1Impl } from "@sb1impl/sparebank1.ts"
// TODO move tsx to devDependency. Requires ts support for Node with support for @ alias
// TODO verbatimSyntax in tsconfig, conflicts with jest
// TODO store last fetched date in db, and refetch from that date, if app has been offline for some time
// TODO do not fetch if saturday or sunday
async function main(): Promise<void> {
logger.info("Starting application")
@ -38,6 +37,11 @@ export async function moveTransactions(
)
logger.info(`Fetched ${actualTransactions.length} transactions`)
if (actualTransactions.length === 0) {
logger.debug("No transactions to import, skipping")
return
}
const transactionsByAccount = Object.groupBy(
actualTransactions,
(transaction) => transaction.account,