-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created ActivityLog models and controllers. Now, each classification …
…inserts a log activity on database. Also, added server routes to make feedbacks.
- Loading branch information
1 parent
b82eae4
commit a41ea69
Showing
5 changed files
with
149 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Created by maiquel on 07/03/18. | ||
*/ | ||
|
||
(function () { | ||
"use strict"; | ||
|
||
const activityLogModel = require("../model/activityLogModel"); | ||
|
||
let activityLogController = () => { | ||
|
||
let createActivity = (classificationResult, callback) => { | ||
|
||
let activity = new activityLogModel(); | ||
activity.text = classificationResult.text; | ||
activity.result = classificationResult; | ||
activity.datetime = new Date(); | ||
|
||
activity.save((err, newActivity) => { | ||
if (err) { | ||
console.log(err); | ||
} | ||
else { | ||
console.log("Atividade salva com id: " + newActivity._id); | ||
callback(newActivity) | ||
} | ||
}); | ||
}; | ||
|
||
let updateActivity = (activityID, feedback, callback) => { | ||
activityLogModel.findByIdAndUpdate(activityID, {feedback: feedback}, callback); | ||
}; | ||
|
||
return { | ||
createActivity: createActivity, | ||
updateActivity: updateActivity | ||
} | ||
|
||
}; | ||
|
||
module.exports = activityLogController(); | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Created by maiquel on 07/03/18. | ||
*/ | ||
|
||
(function () { | ||
"use strict"; | ||
|
||
|
||
let mongoose = require("mongoose"), | ||
Schema = mongoose.Schema; | ||
|
||
let activityLogSchema = new Schema({ | ||
text: { | ||
type: String, | ||
required: true | ||
}, | ||
result: { | ||
type: Object, | ||
required: true | ||
}, | ||
datetime: { | ||
type: Date, | ||
required: true | ||
}, | ||
feedback: { | ||
type: Boolean, | ||
} | ||
}); | ||
|
||
module.exports = mongoose.model('ActivityLog', activityLogSchema); | ||
|
||
}()); |