Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automated old status cleaning interval every hour #113

Merged
merged 2 commits into from
Jan 25, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions back-end/domain/status/StatusManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class StatusManager {
this.statuses = [];

this.setListeners();

setInterval(() => this.checkForOldStatuses(), 1000 * 60 * 60);
}

setListeners() {
Expand Down Expand Up @@ -71,6 +73,18 @@ class StatusManager {
this.statuses = this.statuses.filter(status => !status.isOld());
}

checkForOldStatuses() {
rick-nu marked this conversation as resolved.
Show resolved Hide resolved
const statusCount = this.statuses.length;

this.removeOldStatuses();

// If statuses are removed, push that the statuses are updated
if (this.statuses.length < statusCount) {
console.log('[StatusManager] Old statuses have been removed.');
Events.push(Events.event.statusesUpdated);
}
}

/**
* @param {Status} status
*/
Expand Down