remove old console.logs

This commit is contained in:
Matteo Pagliazzi
2017-09-17 22:08:30 +02:00
parent 0b0baf2195
commit ff92f14a5b

View File

@@ -289,7 +289,6 @@ export default {
}, },
}, },
/* eslint-disable no-console */
mounted () { mounted () {
Promise.all([ Promise.all([
this.$store.dispatch('user:fetch'), this.$store.dispatch('user:fetch'),
@@ -311,7 +310,6 @@ export default {
this.goto('intro', 0); this.goto('intro', 0);
}, 2000); }, 2000);
console.log('before first yesterDailies run, current time:', (new Date()).toString());
this.runYesterDailies(); this.runYesterDailies();
// Do not remove the event listener as it's live for the entire app lifetime // Do not remove the event listener as it's live for the entire app lifetime
@@ -334,45 +332,30 @@ export default {
} }
}, 1000), }, 1000),
scheduleNextCron () { scheduleNextCron () {
console.log('scheduling next cron (scheduleNextCron fn), current time:', (new Date()).toString());
// Open yesterdailies modal the next time cron runs // Open yesterdailies modal the next time cron runs
const dayStart = this.user.preferences.dayStart; const dayStart = this.user.preferences.dayStart;
let nextCron = moment().hours(dayStart).minutes(0).seconds(0).milliseconds(0); let nextCron = moment().hours(dayStart).minutes(0).seconds(0).milliseconds(0);
console.log(
'scheduling next cron, current time:', (new Date()).toString(),
'dayStart', dayStart,
'nextCron (base)', (new Date(nextCron.toDate())).toString());
const currentHour = moment().format('H'); const currentHour = moment().format('H');
if (currentHour >= dayStart) { if (currentHour >= dayStart) {
nextCron = nextCron.add(1, 'day'); nextCron = nextCron.add(1, 'day');
} }
console.log('next cron after edit', nextCron.toDate());
// Setup a listener that executes 10 seconds after the next cron time // Setup a listener that executes 10 seconds after the next cron time
this.nextCron = Number(nextCron.format('x')); this.nextCron = Number(nextCron.format('x'));
this.isRunningYesterdailies = false; this.isRunningYesterdailies = false;
console.log('finished running yesterDailies');
}, },
async runYesterDailies () { async runYesterDailies () {
console.log('isRunningYesterdailies:', this.isRunningYesterdailies, (new Date()).toString());
// @TODO: Hopefully we don't need this even we load correctly
if (this.isRunningYesterdailies) return; if (this.isRunningYesterdailies) return;
console.log('running yesterdailies at, current time:', new Date(), 'needsCron:', this.user.needsCron);
this.isRunningYesterdailies = true; this.isRunningYesterdailies = true;
if (!this.user.needsCron) { if (!this.user.needsCron) {
console.log('cron not needed, scheduling, current time:', (new Date()).toString());
this.handleUserNotifications(this.user.notifications); this.handleUserNotifications(this.user.notifications);
this.scheduleNextCron(); this.scheduleNextCron();
return; return;
} }
let dailys = this.$store.state.tasks.data.dailys; let dailys = this.$store.state.tasks.data.dailys;
console.log('running yesterdailies (real part), current time:', (new Date()).toString());
let yesterDay = moment().subtract('1', 'day').startOf('day').add({ let yesterDay = moment().subtract('1', 'day').startOf('day').add({
hours: this.user.preferences.dayStart, hours: this.user.preferences.dayStart,
@@ -385,40 +368,29 @@ export default {
if (task.yesterDaily && due) this.yesterDailies.push(task); if (task.yesterDaily && due) this.yesterDailies.push(task);
}); });
console.log('yesterDailies to do', this.yesterDailies.length);
if (this.yesterDailies.length === 0) { if (this.yesterDailies.length === 0) {
console.log('no yesterDailies, scheduling cron, current time:', (new Date()).toString());
this.runYesterDailiesAction(); this.runYesterDailiesAction();
return; return;
} }
console.log('showing yesterDailies modal, current time:', (new Date()).toString());
this.$root.$emit('show::modal', 'yesterdaily'); this.$root.$emit('show::modal', 'yesterdaily');
}, },
async runYesterDailiesAction () { async runYesterDailiesAction () {
console.log('yesterDailies action, current time:', (new Date()).toString());
// Run Cron // Run Cron
await axios.post('/api/v3/cron'); await axios.post('/api/v3/cron');
console.log('after /cron call, current time:', (new Date()).toString());
// Notifications // Notifications
// Sync // Sync
// @TODO add a loading spinner somewhere // @TODO add a loading spinner somewhere
console.log('syncing user after cron, current time:', (new Date()).toString());
await Promise.all([ await Promise.all([
this.$store.dispatch('user:fetch', {forceLoad: true}), this.$store.dispatch('user:fetch', {forceLoad: true}),
this.$store.dispatch('tasks:fetchUserTasks', {forceLoad: true}), this.$store.dispatch('tasks:fetchUserTasks', {forceLoad: true}),
]); ]);
console.log('synced user after cron, current time:', (new Date()).toString());
this.handleUserNotifications(this.user.notifications); this.handleUserNotifications(this.user.notifications);
console.log('scheduling next cron after runYesterDailiesAction, current time:', (new Date()).toString());
this.scheduleNextCron(); this.scheduleNextCron();
}, },
/* eslint-enable no-console */
transferGroupNotification (notification) { transferGroupNotification (notification) {
if (!this.user.groupNotifications) this.user.groupNotifications = []; if (!this.user.groupNotifications) this.user.groupNotifications = [];