perf: use dateRange
gitea/salix-front/pipeline/pr-master This commit looks good Details

This commit is contained in:
Javier Segarra 2024-12-31 10:48:07 +01:00
parent 229130409a
commit b6161a41e8
1 changed files with 4 additions and 9 deletions

View File

@ -2,7 +2,7 @@
import { ref, computed, onBeforeMount } from 'vue';
import axios from 'axios';
import { useI18n } from 'vue-i18n';
import { toDate } from 'src/filters/index';
import { dateRange, toDate } from 'src/filters/index';
import { useRoute } from 'vue-router';
import VnTable from 'components/VnTable/VnTable.vue';
@ -140,14 +140,9 @@ const updateDateParams = (value, params) => {
const { dated, previousDays, scopeDays } = campaign;
const _date = new Date(dated);
_date.setHours(0, 0, 0, 0);
params.from = new Date(
new Date(dated).setDate(_date.getDate() - previousDays)
).toISOString();
_date.setHours(23, 59, 59, 59);
params.to = new Date(
new Date(dated).setDate(_date.getDate() + scopeDays)
).toISOString();
const [from, to] = dateRange(_date);
params.from = new Date(from.setDate(from.getDate() - previousDays)).toISOString();
params.to = new Date(to.setDate(to.getDate() + scopeDays)).toISOString();
return params;
};
</script>