-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(functions): improve payment process and improve local functio…
…ns testing setup
- Loading branch information
Showing
62 changed files
with
1,839 additions
and
1,582 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ons/src/cron/ExchangeRateImporter.test.ts → ...-rate-import/ExchangeRateImporter.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as functions from 'firebase-functions'; | ||
import { DateTime } from 'luxon'; | ||
import { ExchangeRateImporter } from './ExchangeRateImporter'; | ||
|
||
/** | ||
* Function periodically scrapes currency exchange rates and saves them to firebase | ||
*/ | ||
export default functions | ||
.runWith({ | ||
timeoutSeconds: 540, | ||
}) | ||
.pubsub.schedule('0 1 * * *') | ||
.onRun(async () => { | ||
const exchangeRateImporter = new ExchangeRateImporter(); | ||
const existingExchangeRates = await exchangeRateImporter.getAllExchangeRates(); | ||
for ( | ||
let timestamp = ExchangeRateImporter.startTimestamp; | ||
timestamp <= Date.now() / 1000; | ||
timestamp += ExchangeRateImporter.secondsInDay | ||
) { | ||
if (!existingExchangeRates.has(timestamp)) { | ||
try { | ||
await exchangeRateImporter.fetchAndStoreExchangeRates(DateTime.fromSeconds(timestamp)); | ||
} catch (error) { | ||
functions.logger.error(`Could not ingest exchange rate`, error); | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { ExchangeRateImporter } from './ExchangeRateImporter'; | ||
import { PostFinanceImporter } from './PostFinanceImporter'; | ||
import importExchangeRatesFunction from './exchange-rate-import'; | ||
import importBalanceMailFunction from './postfinance-import'; | ||
|
||
export const importBalanceMail = new PostFinanceImporter().getFunction(); | ||
export const importExchangeRates = new ExchangeRateImporter().getFunction(); | ||
export const importBalanceMail = importBalanceMailFunction; | ||
export const importExchangeRates = importExchangeRatesFunction; |
8 changes: 4 additions & 4 deletions
8
...ions/src/cron/PostfinanceImporter.test.ts → ...inance-import/PostFinanceImporter.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.