-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistory.js
32 lines (27 loc) · 944 Bytes
/
history.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var functions = require("./util.js");
const service = "history";
class history {
constructor(store) {
this.store = store;
this.service = service;
this.history = store.getTable("History");
}
async manageGet(queryString) { }
async managePost(body) {
let idUser = this.store.getIdUser(body.idSession);
if (body.method == "addHistory") {
let add = h => {
if (this.store.searchKey("Exercise", "idExercise", h.idExercise) != undefined) {
this.history.push({ idUser: idUser, date: new Date(), idExercise: h.idExercise });
}
}
if (Array.isArray(body.data)) {
body.data.array.forEach(add);
} else {
add(body.data);
}
this.store.saveData("History", this.history);
}
}
}
module.exports = history