add: adding all files

This commit is contained in:
Randell Dawson
2018-11-06 23:04:43 -08:00
parent 40f7f9713e
commit 755e44bf4c
16 changed files with 1339 additions and 0 deletions

48
prProcessingLog.js Normal file
View File

@@ -0,0 +1,48 @@
const fs = require('fs');
const { saveToFile } = require('./fileFunctions');
class PrProcessingLog {
constructor() {
this._start = null,
this._lastUpdate = null,
this._lastPRlogged = null,
this._finish = null,
this._prs = {}
this._logfile = 'data/open-prs-processed.json'
}
import() {
return JSON.parse(fs.readFileSync(this._logfile, 'utf8'));
}
export() {
let sortedPRs = Object.keys(this._prs)
.sort((a, b) => a - b)
.map(num => ({ [num]: this._prs[num] }));
const log = {
start: this._start,
finish: this._finish,
prs: sortedPRs
};
saveToFile(this._logfile, JSON.stringify(log))
}
add(prNum) {
this._prs[prNum] = null;
}
update(prNum, status) {
this._prs[prNum] = status;
}
start() {
this._start = new Date();
}
finish() {
this._finish = new Date();
this.export();
}
};
exports.PrProcessingLog = PrProcessingLog;