diff --git a/ayanova/src/views/svc-schedule.vue b/ayanova/src/views/svc-schedule.vue index da5b4551..1036c13c 100644 --- a/ayanova/src/views/svc-schedule.vue +++ b/ayanova/src/views/svc-schedule.vue @@ -823,9 +823,7 @@ export default { }, async fetchEvents({ start, end }) { try { - console.time("fetchEvents"); window.$gz.form.deleteAllErrorBoxErrors(this); - console.timeLog("fetchEvents"); const res = await window.$gz.api.post("schedule/svc", { view: window.$gz.util.calendarViewToAyaNovaEnum(this.viewType), dark: this.$store.state.darkMode, @@ -843,13 +841,105 @@ export default { reminders: this.formUserOptions.reminders, users: this.formUserOptions.users }); - console.timeLog("fetchEvents"); + if (res.error) { this.formState.serverError = res.error; window.$gz.form.setErrorBoxErrors(this); } else { const vm = this; - this.events = res.data.map(x => { + + /* + 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]; + 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, + category: vm.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( @@ -863,12 +953,10 @@ export default { category: vm.availableUsers.find(a => a.id == x.userId).name }; }); - console.timeLog("fetchEvents"); +*/ } } catch (error) { window.$gz.errorHandler.handleFormError(error, this); - } finally { - console.timeEnd("fetchEvents"); } }, async saveUserOptions() {