perf: date proposal
gitea/hedera-web/pipeline/pr-4922-vueMigration This commit looks good Details

This commit is contained in:
Javier Segarra 2024-08-22 23:32:47 +02:00
parent 053b9f8457
commit 5456db8add
2 changed files with 6 additions and 7 deletions

View File

@ -6,7 +6,7 @@ export function currency(val) {
return typeof val === 'number' ? val.toFixed(2) + '€' : val;
}
export function date(val, format) {
export function date(val, format = 'YYYY-MM-DD') {
if (val == null) return val;
if (!(val instanceof Date)) {
val = new Date(val);

View File

@ -2,11 +2,10 @@
import { ref, inject, watch, computed } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { date as qdate } from 'quasar';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import { formatDateTitle } from 'src/lib/filters.js';
import { formatDateTitle, date } from 'src/lib/filters.js';
import { useAppStore } from 'stores/app';
import { storeToRefs } from 'pinia';
@ -39,8 +38,8 @@ const getVisits = async () => {
WHERE c.stamp BETWEEN TIMESTAMP(#from,'00:00:00') AND TIMESTAMP(#to,'23:59:59')
GROUP BY browser ORDER BY visits DESC`,
{
from: qdate.formatDate(from.value, 'YYYY-MM-DD'),
to: qdate.formatDate(to.value, 'YYYY-MM-DD')
from: date(from.value),
to: date(to.value)
}
);
visitsData.value = visitsResponse;
@ -60,8 +59,8 @@ watch(
async () => {
await router.replace({
query: {
from: qdate.formatDate(from.value, 'YYYY-MM-DD'),
to: qdate.formatDate(to.value, 'YYYY-MM-DD')
from: date(from.value),
to: date(to.value)
}
});
await getVisits();