Last active
August 29, 2015 13:58
-
-
Save keepcosmos/10344167 to your computer and use it in GitHub Desktop.
Revisions
-
keepcosmos revised this gist
Apr 10, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ db.messenger_rooms.mapReduce( function(){ var date = new Date(this.created_at); date.setHours(date.getHours()); var dateKey = (date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()); var reserved_count = (this.reservation_status == undefined || this.reservation_status == null) ? 0 : 1; emit(dateKey, {count: 1, reserved_count: reserved_count}); -
keepcosmos created this gist
Apr 10, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ db.messenger_rooms.mapReduce( function(){ var date = new Date(this.created_at); date.setHours(date.getHours() + 9); var dateKey = (date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()); var reserved_count = (this.reservation_status == undefined || this.reservation_status == null) ? 0 : 1; emit(dateKey, {count: 1, reserved_count: reserved_count}); }, function(key, values){ var sum = {count: 0, reserved_count: 0} values.forEach(function(value){ sum["count"] += value["count"]; sum["reserved_count"] += value["reserved_count"]; }); return sum; }, { query: { created_at: {$gte: ISODate("2014-04-01"), $lte: ISODate("2014-04-03")} }, out: "daily_rooms_count" } )