Skip to content

Commit e455153

Browse files
committed
Add createdAt timestamp to observations
1 parent f8dd4b6 commit e455153

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@ All notable changes to this project will be documented in this file.
33
Adheres to [Semantic Versioning](http://semver.org/).
44

55
---
6-
## 4.5.1 (TBD)
6+
## 4.5.2 (TBD)
77

88
* TBD
99

1010
##### Features
1111

1212
##### Bug Fixes
1313

14+
## [4.5.1](https://github.com/ngageoint/mage-server/releases/tag/4.5.1) (07-11-2017)
15+
16+
##### Features
17+
* Added createdAt timestamp for observations
18+
19+
##### Bug Fixes
20+
1421
## [4.5.0](https://github.com/ngageoint/mage-server/releases/tag/4.5.0) (05-26-2017)
1522

1623
##### Features

models/observation.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ var ObservationSchema = new Schema({
5858
},
5959
favoriteUserIds: [{type: Schema.Types.ObjectId, ref: 'User'}]
6060
},{
61-
strict: false
61+
strict: false,
62+
timestamps: {
63+
createdAt: 'createdAt',
64+
updatedAt: 'lastModified'
65+
}
6266
});
6367

6468
ObservationSchema.index({geometry: "2dsphere"});
@@ -237,8 +241,6 @@ exports.getObservations = function(event, o, callback) {
237241

238242
// DEPRECATED backwards compat for creating an observation. Will be removed in version 5.x.x
239243
exports.createObservation = function(event, observation, callback) {
240-
observation.lastModified = moment.utc().toDate();
241-
242244
observationModel(event).create(observation, callback);
243245
};
244246

@@ -263,8 +265,6 @@ exports.getObservationById = function(event, observationId, options, callback) {
263265
};
264266

265267
exports.updateObservation = function(event, observationId, observation, callback) {
266-
observation.lastModified = moment.utc().toDate();
267-
268268
observationModel(event).findByIdAndUpdate(observationId, observation, {new: true, upsert: true}, callback);
269269
};
270270

@@ -318,9 +318,6 @@ exports.addState = function(event, id, state, callback) {
318318
'$each': [state],
319319
'$position': 0
320320
}
321-
},
322-
'$set': {
323-
lastModified: moment.utc().toDate()
324321
}
325322
};
326323

@@ -333,9 +330,6 @@ exports.addFavorite = function(event, observationId, user, callback) {
333330
var update = {
334331
$addToSet: {
335332
favoriteUserIds: user._id
336-
},
337-
'$set': {
338-
lastModified: moment.utc().toDate()
339333
}
340334
};
341335

@@ -346,9 +340,6 @@ exports.removeFavorite = function (event, observationId, user, callback) {
346340
var update = {
347341
$pull: {
348342
favoriteUserIds: user._id
349-
},
350-
'$set': {
351-
lastModified: moment.utc().toDate()
352343
}
353344
};
354345

@@ -359,9 +350,6 @@ exports.removeImportant = function(event, id, callback) {
359350
var update = {
360351
'$unset': {
361352
important: 1
362-
},
363-
'$set': {
364-
lastModified: moment.utc().toDate()
365353
}
366354
};
367355

@@ -396,7 +384,7 @@ exports.addAttachment = function(event, id, file, callback) {
396384
lastModified: new Date()
397385
});
398386

399-
var update = {'$push': { attachments: attachment }, 'lastModified': new Date()};
387+
var update = {'$push': { attachments: attachment }};
400388
observationModel(event).update(condition, update, function(err) {
401389
callback(err, attachment);
402390
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "MAGE",
3-
"version": "4.5.0",
3+
"version": "4.5.1",
44
"description": "Geospatial situation awareness application",
55
"keywords": [
66
"NGA",

0 commit comments

Comments
 (0)