fetch speed up implemented fully

This commit is contained in:
2021-10-05 19:21:46 +00:00
parent cb17995a9f
commit c3d3cb3388
3 changed files with 47 additions and 101 deletions

View File

@@ -838,19 +838,36 @@ export default {
this.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(this);
} else {
this.events = res.data.map(x => {
return {
...x,
start: window.$gz.locale.utcDateToScheduleCompatibleFormatLocalized(
x.start,
this.timeZoneName
),
end: window.$gz.locale.utcDateToScheduleCompatibleFormatLocalized(
x.end,
this.timeZoneName
)
};
});
this.events.splice(0);
const timeZoneName = this.timeZoneName;
let i = res.data.length;
while (i--) {
const x = res.data[i];
this.events.push({
start: new Date(
new Date(x.start)
.toLocaleString("sv-SE", {
timeZone: timeZoneName
})
.replace(" ", "T")
).getTime(),
end: new Date(
new Date(x.end)
.toLocaleString("sv-SE", {
timeZone: timeZoneName
})
.replace(" ", "T")
).getTime(),
timed: true,
name: x.name,
color: x.color,
textColor: x.textColor,
type: x.type,
id: x.id,
editable: x.editable,
userId: x.userId
});
}
}
} catch (error) {
window.$gz.errorHandler.handleFormError(error, this);

View File

@@ -836,7 +836,7 @@ export default {
this.timeZoneName
),
wisuColorSource: this.formUserOptions.wisuColorSource,
wisu: this.formUserOptions.wisu, //workorder item scheduled user records
wisu: this.formUserOptions.wisu,
reviews: this.formUserOptions.reviews,
reminders: this.formUserOptions.reminders,
users: this.formUserOptions.users
@@ -846,25 +846,8 @@ export default {
this.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(this);
} else {
const vm = this;
/*
return new Date(
new Date(value) //convert to locale timezone and output in the closest thing to iso-8601 format
.toLocaleString("sv-SE", {
timeZone: timeZoneName
})
.replace(" ", "T") //Safari can't parse the date from here because sv-SE puts a space between date and time and Safari will only parse if it has a T between
).getTime();
*/
//=============================================
//HOT LOOP
//=============================================
console.time("process");
// const t = [];
this.events.splice(0);
const timeZoneName = this.timeZoneName;
let i = res.data.length;
while (i--) {
const x = res.data[i];
@@ -891,69 +874,9 @@ export default {
id: x.id,
editable: x.editable,
userId: x.userId,
category: vm.availableUsers.find(a => a.id == x.userId).name
category: this.availableUsers.find(a => a.id == x.userId).name
});
}
//this.events = t;
// this.events = res.data.map(x => {
// return {
// ...x,
// start: window.$gz.locale.utcDateToScheduleCompatibleFormatLocalized(
// x.start,
// this.timeZoneName
// ),
// end: window.$gz.locale.utcDateToScheduleCompatibleFormatLocalized(
// x.end,
// this.timeZoneName
// ),
// category: vm.availableUsers.find(a => a.id == x.userId).name
// };
// });
// t;
//====================================================
console.timeEnd("process");
//console.log(`processed ${this.events.length} items`);
/*
sept baseline
process: 4632ms - timer ended svc-schedule.vue:882
process: 19ms - timer ended svc-schedule.vue:882
process: 4467ms - timer ended
none under 4 seconds
{
"0": {
"start": "2021-09-02T00:00:00Z",
"end": "2021-09-02T04:00:00Z",
"timed": true,
"name": "3 Windler - Gerhold",
"color": "#FCF1C2",
"textColor": "black",
"type": 41,
"id": 41,
"editable": false,
"userId": 41
}
}
this.events = res.data.map(x => {
return {
...x,
start: window.$gz.locale.utcDateToScheduleCompatibleFormatLocalized(
x.start,
this.timeZoneName
),
end: window.$gz.locale.utcDateToScheduleCompatibleFormatLocalized(
x.end,
this.timeZoneName
),
category: vm.availableUsers.find(a => a.id == x.userId).name
};
});
*/
}
} catch (error) {
window.$gz.errorHandler.handleFormError(error, this);