Method should not be async

This commit is contained in:
James Cole
2023-10-07 07:20:01 +02:00
parent 8e183d8cad
commit 2ea9369f99
10 changed files with 24 additions and 30 deletions

File diff suppressed because one or more lines are too long

View File

@@ -30,10 +30,10 @@
"integrity": "sha384-B73JAwYNSgI4rwb14zwxigHgAkg1Ms+j6+9sJoDpiL11+VW5RjQCLfIh0RVoi0h6"
},
"resources/assets/v2/pages/dashboard/dashboard.js": {
"file": "assets/dashboard-9c9be7cf.js",
"file": "assets/dashboard-2100f404.js",
"isEntry": true,
"src": "resources/assets/v2/pages/dashboard/dashboard.js",
"integrity": "sha384-fpX8mrTJxfFxKxTS5d9M+3SJnQE9ePo1Re15lATVi+Q165igCJ6/Rs/mXyezYI4G"
"integrity": "sha384-V9FlCSPQuNaRj8izLok2N3wJYIFCKB/T3n+8gr7HB1r90GH086BF99Wrwel2tHnQ"
},
"resources/assets/v2/sass/app.scss": {
"file": "assets/app-28a195fd.css",

View File

@@ -35,9 +35,6 @@ let chart = null;
let chartData = null;
let afterPromises = false;
const CHART_CACHE_KEY = 'dashboard-accounts-chart';
const ACCOUNTS_CACHE_KEY = 'dashboard-accounts-data';
export default () => ({
loading: false,
loadingAccounts: false,
@@ -51,12 +48,13 @@ export default () => ({
getFreshData() {
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const chartCacheKey = getCacheKey(CHART_CACHE_KEY, start, end)
const chartCacheKey = getCacheKey('dashboard-accounts-chart', start, end)
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(chartCacheKey);
if (cacheValid && typeof cachedData !== 'undefined') {
console.log(cachedData);
this.drawChart(this.generateOptions(cachedData));
this.loading = false;
return;
@@ -66,6 +64,7 @@ export default () => ({
this.chartData = response.data;
// cache generated options:
window.store.set(chartCacheKey, response.data);
console.log(response.data);
this.drawChart(this.generateOptions(this.chartData));
this.loading = false;
});
@@ -168,7 +167,7 @@ export default () => ({
}
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const accountCacheKey = getCacheKey(ACCOUNTS_CACHE_KEY, start, end);
const accountCacheKey = getCacheKey('dashboard-accounts-data', start, end);
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(accountCacheKey);

View File

@@ -25,7 +25,6 @@ import formatMoney from "../../util/format-money.js";
import {getCacheKey} from "../../support/get-cache-key.js";
let afterPromises = false;
const CACHE_KEY = 'dashboard-boxes-data';
export default () => ({
balanceBox: {amounts: [], subtitles: []},
billBox: {paid: [], unpaid: []},
@@ -38,7 +37,7 @@ export default () => ({
getFreshData() {
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const boxesCacheKey = getCacheKey(CACHE_KEY, start, end);
const boxesCacheKey = getCacheKey('dashboard-boxes-data', start, end);
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(boxesCacheKey);

View File

@@ -34,7 +34,6 @@ let afterPromises = false;
let i18n; // for translating items in the chart.
const CACHE_KEY = 'dashboard-budgets-chart';
export default () => ({
loading: false,
autoConversion: false,
@@ -62,7 +61,7 @@ export default () => ({
getFreshData() {
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const cacheKey = getCacheKey(CACHE_KEY, start, end);
const cacheKey = getCacheKey('dashboard-budgets-chart', start, end);
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(cacheKey);

View File

@@ -30,8 +30,6 @@ let chart = null;
let chartData = null;
let afterPromises = false;
const CACHE_KEY = 'dashboard-categories-chart';
export default () => ({
loading: false,
autoConversion: false,
@@ -149,7 +147,7 @@ export default () => ({
getFreshData() {
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const cacheKey = getCacheKey(CACHE_KEY, start, end);
const cacheKey = getCacheKey('dashboard-categories-chart', start, end);
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(cacheKey);

View File

@@ -27,7 +27,7 @@ import {format} from "date-fns";
let apiData = {};
let afterPromises = false;
let i18n;
const CACHE_KEY = 'dashboard-piggies-data';
const PIGGY_CACHE_KEY = 'dashboard-piggies-data';
export default () => ({
loading: false,
@@ -37,7 +37,7 @@ export default () => ({
getFreshData() {
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const cacheKey = getCacheKey(CACHE_KEY, start, end);
const cacheKey = getCacheKey(PIGGY_CACHE_KEY, start, end);
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(cacheKey);
@@ -59,7 +59,7 @@ export default () => ({
downloadPiggyBanks(params) {
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const cacheKey = getCacheKey(CACHE_KEY, start, end);
const cacheKey = getCacheKey(PIGGY_CACHE_KEY, start, end);
const getter = new Get();
getter.get(params).then((response) => {
apiData = [...apiData, ...response.data.data];

View File

@@ -29,7 +29,7 @@ import {format} from "date-fns";
Chart.register({SankeyController, Flow});
const CACHE_KEY = 'dashboard-sankey-data';
const SANKEY_CACHE_KEY = 'dashboard-sankey-data';
let i18n;
let currencies = [];
let afterPromises = false;
@@ -290,7 +290,7 @@ export default () => ({
getFreshData() {
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const cacheKey = getCacheKey(CACHE_KEY, start, end);
const cacheKey = getCacheKey(SANKEY_CACHE_KEY, start, end);
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(cacheKey);
@@ -314,7 +314,7 @@ export default () => ({
downloadTransactions(params) {
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const cacheKey = getCacheKey(CACHE_KEY, start, end);
const cacheKey = getCacheKey(SANKEY_CACHE_KEY, start, end);
//console.log('Downloading page ' + params.page + '...');
const getter = new Get();

View File

@@ -32,7 +32,6 @@ import formatMoney from "../../util/format-money.js";
let afterPromises = false;
let i18n; // for translating items in the chart.
let apiData = [];
const SUBSCRIPTION_CACHE_KEY = 'subscriptions-data-dashboard';
let subscriptionData = {};
function downloadSubscriptions(params) {
@@ -191,7 +190,7 @@ export default () => ({
console.log('here we are');
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(getCacheKey(SUBSCRIPTION_CACHE_KEY, start, end));
let cachedData = window.store.get(getCacheKey('subscriptions-data-dashboard', start, end));
if (cacheValid && typeof cachedData !== 'undefined' && false) {
console.error('cannot handle yet');

View File

@@ -20,10 +20,10 @@
import {format} from "date-fns";
async function getCacheKey(string, start, end) {
function getCacheKey(string, start, end) {
const cacheKey = format(start, 'y-MM-dd') + '_' + format(end, 'y-MM-dd') + '_' + string;
console.log('getCacheKey: ' + cacheKey);
return cacheKey;
return String(cacheKey);
}
export {getCacheKey};