Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 optimise GoCardless bank sync to use fewer api calls #3279

Merged
merged 6 commits into from
Aug 26, 2024

Conversation

matt-fidd
Copy link
Contributor

@matt-fidd matt-fidd commented Aug 17, 2024

Part of actualbudget/actual-server#431
Complimentary PR to actualbudget/actual-server#436

The balance fetched from GoCardless is used to calculate the starting balance, which is only relevant when a completely blank account is synced. This change reduces the amount of API calls per sync, once the account has had a starting balance set, to 1 - maximising the new 10 requests/day rate limit coming on the 19th.

@actual-github-bot actual-github-bot bot changed the title Optimise gocardless bank sync to use fewer api calls [WIP] Optimise gocardless bank sync to use fewer api calls Aug 17, 2024
Copy link

netlify bot commented Aug 17, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 03cec83
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/66c28b7be1c5a00008d38e4c
😎 Deploy Preview https://deploy-preview-3279.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Aug 17, 2024

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
9 5.2 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/usePreviewTransactions.js 1.59 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/AppliedFilters.js 27.9 kB 0%
static/js/narrow.js 77.58 kB 0%
static/js/wide.js 223.52 kB 0%
static/js/ReportRouter.js 1.48 MB 0%
static/js/index.js 3.25 MB 0%

Copy link
Contributor

github-actions bot commented Aug 17, 2024

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.16 MB → 1.16 MB (-42 B) -0.00%
Changeset
File Δ Size
packages/loot-core/src/server/accounts/sync.ts 📉 -15 B (-0.06%) 23.79 kB → 23.77 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

Asset File Size % Changed
kcab.worker.js 1.16 MB → 1.16 MB (-42 B) -0.00%

Unchanged

No assets were unchanged

@matt-fidd matt-fidd changed the title [WIP] Optimise gocardless bank sync to use fewer api calls Optimise gocardless bank sync to use fewer api calls Aug 17, 2024
@matt-fidd matt-fidd changed the title Optimise gocardless bank sync to use fewer api calls 🧹 Optimise GoCardless bank sync to use fewer api calls Aug 17, 2024
@matt-fidd matt-fidd changed the title 🧹 Optimise GoCardless bank sync to use fewer api calls 🧹 optimise GoCardless bank sync to use fewer api calls Aug 17, 2024
packages/loot-core/src/server/accounts/sync.ts Outdated Show resolved Hide resolved
Comment on lines +115 to +119
const {
transactions: { all },
balances,
startingBalance,
} = res;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar question as below, why not just build what we want to return and then return res?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer it in this case to the alternative:

    return {                                                                    
      transactions: res.transactions.all,                                       
      accountBalance: res.balances,                                             
      startingBalance: res.startingBalance,                                     
    };

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also want to log the original res out for debugging purposes

@matt-fidd matt-fidd merged commit d9adb75 into actualbudget:master Aug 26, 2024
19 checks passed
@matt-fidd matt-fidd deleted the optimise branch August 26, 2024 10:04
@yoyotogblo
Copy link
Contributor

yoyotogblo commented Sep 7, 2024

Any reason why you removed the accountBalance from SimpleFin transactions? I download that in my instance and add it to the account notes. It's a great way to see what my balance is and to reconcile my transactions.

@matt-fidd
Copy link
Contributor Author

Any reason why you removed the accountBalance from SimpleFin transactions? I download that in my instance and add it to the account notes. It's a great way to see what my balance is and to reconcile my transactions.

Yes, it wasn't used anywhere in the code base.
I'll add it back for simplefin as it doesn't hurt to be there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants