Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Commit

Permalink
Do not request transactions when listing accounts (#482)
Browse files Browse the repository at this point in the history
* Do not request transactions when listing accounts

* add release note

* fix linter
  • Loading branch information
psybers authored Oct 23, 2024
1 parent cc347ae commit c9e6d78
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/app-simplefin/app-simplefin.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ app.post(
return;
}

const now = new Date();
const startDate = new Date(now.getFullYear(), now.getMonth(), 1);
const endDate = new Date(now.getFullYear(), now.getMonth() + 1, 1);

try {
const accounts = await getAccounts(accessKey, startDate, endDate);
const accounts = await getAccounts(accessKey, null, null, true);

res.send({
status: 'ok',
Expand Down Expand Up @@ -313,7 +309,12 @@ function normalizeDate(date) {
return (date.valueOf() - date.getTimezoneOffset() * 60 * 1000) / 1000;
}

async function getAccounts(accessKey, startDate, endDate) {
async function getAccounts(
accessKey,
startDate,
endDate,
noTransactions = false,
) {
const sfin = parseAccessKey(accessKey);
const options = {
headers: {
Expand All @@ -323,16 +324,20 @@ async function getAccounts(accessKey, startDate, endDate) {
},
};
const params = [];
let queryString = '';
if (startDate) {
params.push(`start-date=${normalizeDate(startDate)}`);
}
if (endDate) {
params.push(`end-date=${normalizeDate(endDate)}`);
}
if (!noTransactions) {
if (startDate) {
params.push(`start-date=${normalizeDate(startDate)}`);
}
if (endDate) {
params.push(`end-date=${normalizeDate(endDate)}`);
}

params.push(`pending=1`);
params.push(`pending=1`);
} else {
params.push(`balances-only=1`);
}

let queryString = '';
if (params.length > 0) {
queryString += '?' + params.join('&');
}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/482.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [psybers]
---

Don't pull transactions from SimpleFIN when asking for the list of accounts.

0 comments on commit c9e6d78

Please sign in to comment.