blue-button-record
Advanced tools
Comparing version 1.3.0-beta.2 to 1.3.0-beta.3
16
index.js
@@ -154,4 +154,4 @@ "use strict"; | ||
//TODO: inject ptKey to all methods, properly | ||
exports.saveEvent = function (eventName, username, note, file, callback) { | ||
account_history.saveEvent(dbinfo, eventName, username, note, file, callback); | ||
exports.saveEvent = function (eventName, ptKey, note, file, callback) { | ||
account_history.saveEvent(dbinfo, eventName, ptKey, note, file, callback); | ||
}; | ||
@@ -163,12 +163,12 @@ | ||
exports.getAllEvents = function (callback) { | ||
account_history.allEventsInOrder(dbinfo, callback); | ||
exports.getAllEvents = function (ptKey, callback) { | ||
account_history.allEventsInOrder(dbinfo, ptKey, callback); | ||
}; | ||
exports.getRecentLogin = function (callback) { | ||
account_history.lastLogin(dbinfo, callback); | ||
exports.getRecentLogin = function (ptKey, callback) { | ||
account_history.lastLogin(dbinfo, ptKey, callback); | ||
}; | ||
exports.getRecentUpdate = function (callback) { | ||
account_history.lastUpdate(dbinfo, callback); | ||
exports.getRecentUpdate = function (ptKey, callback) { | ||
account_history.lastUpdate(dbinfo, ptKey, callback); | ||
}; |
@@ -22,5 +22,5 @@ "use strict"; | ||
//Used in login, storage, record | ||
exports.saveEvent = function (dbinfo, eventType, username, note, file, callback) { | ||
exports.saveEvent = function (dbinfo, eventType, ptKey, note, file, callback) { | ||
var newEvent = new dbinfo.accountHistoryModel({ | ||
userID: username, //not necessary w/authentication? | ||
username: ptKey, | ||
event_type: eventType, | ||
@@ -42,5 +42,7 @@ note: note, //file descriptor, IP address | ||
exports.allEventsInOrder = function (dbinfo, callback) { | ||
exports.allEventsInOrder = function (dbinfo, ptKey, callback) { | ||
var model = dbinfo.accountHistoryModel; | ||
model.find({}).sort({ | ||
model.find({ | ||
"username": ptKey | ||
}).sort({ | ||
date: -1 | ||
@@ -52,6 +54,8 @@ }).exec(function (err, docs) { | ||
exports.lastLogin = function (dbinfo, callback) { | ||
exports.lastLogin = function (dbinfo, ptKey, callback) { | ||
var model = dbinfo.accountHistoryModel; | ||
var loginQuery = model.find({ | ||
'event_type': 'loggedIn' | ||
'event_type': 'loggedIn', | ||
"username": ptKey | ||
}).sort({ | ||
@@ -79,7 +83,9 @@ date: -1 | ||
exports.lastUpdate = function (dbinfo, callback) { | ||
exports.lastUpdate = function (dbinfo, ptKey, callback) { | ||
var model = dbinfo.accountHistoryModel; | ||
var updateQuery = model.find({ | ||
'event_type': 'fileUploaded' | ||
'event_type': 'fileUploaded', | ||
"username": ptKey | ||
}).sort({ | ||
@@ -86,0 +92,0 @@ date: -1 |
@@ -23,3 +23,3 @@ "use strict"; | ||
}, | ||
userID: String, | ||
username: String, | ||
note: String, | ||
@@ -26,0 +26,0 @@ time: { |
@@ -5,3 +5,3 @@ { | ||
"description": "Master Health Record and Data Reconciliation Engine Persistance Layer", | ||
"version": "1.3.0-beta.2", | ||
"version": "1.3.0-beta.3", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -39,3 +39,3 @@ "use strict"; | ||
record.getRecentLogin(function (err, data) { | ||
record.getRecentLogin("username", function (err, data) { | ||
//console.log("recent login: ", data); | ||
@@ -59,3 +59,3 @@ | ||
record.getRecentUpdate(function (err, data) { | ||
record.getRecentUpdate("username", function (err, data) { | ||
//console.log("recent login: ", data); | ||
@@ -77,3 +77,3 @@ | ||
//record. | ||
record.getAllEvents(function (err, data) { | ||
record.getAllEvents("username", function (err, data) { | ||
@@ -80,0 +80,0 @@ expect(data).to.exist; |
377711
5119