perf: refs #8180 simplify ticket checking by combining hasTickets logic
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2025-05-07 17:24:14 +02:00
parent b68f4331b8
commit d3b6223473
1 changed files with 12 additions and 18 deletions

View File

@ -66,10 +66,7 @@ const excludeType = computed({
const arrayData = useArrayData('ZoneEvents');
const exclusionGeoCreate = async () => {
if (await hasTickets(route.params.id, dated.value)) {
await handleHasTickets();
return;
}
if (await zoneHasTickets(route.params.id, dated.value)) return;
const params = {
zoneFk: parseInt(route.params.id),
@ -92,10 +89,7 @@ const exclusionCreate = async () => {
};
const zoneIds = props.zoneIds?.length ? props.zoneIds : [route.params.id];
for (const id of zoneIds) {
if (await hasTickets(id, dated.value)) {
await handleHasTickets();
return;
}
if (await zoneHasTickets(id, dated.value)) return;
const url = `Zones/${id}/exclusions`;
let today = moment(dated.value);
@ -133,7 +127,7 @@ const exclusionCreate = async () => {
await refetchEvents();
};
const hasTickets = async (zoneId, date) => {
const zoneHasTickets = async (zoneId, date) => {
const filter = {
where: {
zoneFk: zoneId,
@ -142,15 +136,15 @@ const hasTickets = async (zoneId, date) => {
};
const params = { filter: JSON.stringify(filter) };
const { data } = await axios.get('Tickets', { params });
return data.length > 0;
};
const handleHasTickets = async (zoneId, date) => {
quasar.notify({
message: t('eventsExclusionForm.cantCloseZone'),
type: 'negative',
});
await refetchEvents();
if (data.length > 0) {
quasar.notify({
message: t('eventsExclusionForm.cantCloseZone'),
type: 'negative',
});
await refetchEvents();
return true;
}
return false;
};
const onSubmit = async () => {