@accounter/server
Version:
The test suite is split into three Vitest projects for efficiency and isolation:
69 lines • 2.2 kB
JavaScript
import { __decorate, __metadata } from "tslib";
import { Injectable, Scope } from 'graphql-modules';
import { sql } from '@pgtyped/runtime';
import { getCacheInstance } from '../../../shared/helpers/index.js';
import { DBProvider } from '../../app-providers/db.provider.js';
const getAllPensionFunds = sql `
SELECT *
FROM accounter_schema.pension_funds
WHERE accounter_schema.pension_funds.type = 'pension';`;
const getAllTrainingFunds = sql `
SELECT *
FROM accounter_schema.pension_funds
WHERE accounter_schema.pension_funds.type = 'training_fund';`;
const getAllFunds = sql `
SELECT * FROM accounter_schema.pension_funds;`;
let FundsProvider = class FundsProvider {
dbProvider;
cache = getCacheInstance({
stdTTL: 60 * 5,
});
constructor(dbProvider) {
this.dbProvider = dbProvider;
}
getAllPensionFunds() {
const cached = this.cache.get('pension-funds');
if (cached) {
return Promise.resolve(cached);
}
return getAllPensionFunds.run(undefined, this.dbProvider).then(res => {
if (res)
this.cache.set('pension-funds', res);
return res;
});
}
getAllTrainingFunds() {
const cached = this.cache.get('training-funds');
if (cached) {
return Promise.resolve(cached);
}
return getAllTrainingFunds.run(undefined, this.dbProvider).then(res => {
if (res)
this.cache.set('training-funds', res);
return res;
});
}
getAllFunds(params) {
const cached = this.cache.get('all-funds');
if (cached) {
return Promise.resolve(cached);
}
return getAllFunds.run(params, this.dbProvider).then(res => {
if (res)
this.cache.set('all-funds', res);
return res;
});
}
clearCache() {
this.cache.clear();
}
};
FundsProvider = __decorate([
Injectable({
scope: Scope.Singleton,
global: true,
}),
__metadata("design:paramtypes", [DBProvider])
], FundsProvider);
export { FundsProvider };
//# sourceMappingURL=funds.provider.js.map