Am using below mongo db query, while getting output am seeing the output with 08th Jan also, is there any changes needs to implement in query, thanks.
below is the query with timestamp selecting from 07th Jan 00 to 07th Jan 23:59:00, selecting the function status: FO_AE", "nonFO_AE", "FO_AF", "nonFO_AF", "FO_voip", "nonFO_voip", "FO_DS1", "nonFO_DS1"
db.actions.aggregate([{
$match: {
"$and": [{
"timeStamp": {
"$gte": ISODate("2021-01-07T00:00:00.000-0400"),
"$lt": ISODate("2021-01-07T23:59:00.000-0400")
}
}, {
"functionStatus": {
"$in": ["FO_AE", "nonFO_AE", "FO_AF", "nonFO_AF", "FO_voip", "nonFO_voip", "FO_DS1", "nonFO_DS1"]
}
}]
}
},
{
$group: {
_id: {
Dates: {
$dateToString: {
format: "%Y-%m-%d",
date: "$timeStamp"
}
},
FS: "$functionStatus"
},
JOBCOUNT: {
$addToSet: "$jobId"
}
}
},
{
$project: {
"_id": NumberInt(0),
"Dates": "$_id.Dates",
"FS": "$_id.FS",
"Total_JOB_FO_USE_DV": {
$size: "$JOBCOUNT"
}
}
}
])
/* 1 */
{
"Dates" : "2021-01-08",
"FS" : "nonFO_AE",
"Total_JOB_FO_USE_DV"" : 2
}
/* 2 */
{
"Dates" : "2021-01-07",
"FS" : "nonFO_DS1",
"Total_JOB_FO_USE_DV" : 7
}
/* 3 */
{
"Dates" : "2021-01-07",
"FS" : "nonFO_AF",
"Total_JOB_FO_USE_DV"" : 24
}
/* 4 */
{
"Dates" : "2021-01-07",
"FS" : "nonFO_AE",
"Total_JOB_FO_USE_DV"" : 20
}
Thanks expert please find one sample document from collection:
/* 1 */
{
"_id" : 947771683,
"eventId" : "ALSWA-02-13-007",
"eventName" : "",
"timeStamp" : ISODate("2020-10-10T05:47:08.421Z"),
"eventMethod" : "AI response",
"resourceName" : "",
"targetType" : "",
"resourseUrl" : "",
"operationName" : "getLastReleaseNumber",
"functionStatus" : "FO_AE",
"results" : "{\"flowStatus\":\"SUCCESS\",\"flowStatusMessage\":\"\",\"lastRlsNum\":\"0.1\",\"alasUpgTy\":\"F\"}",
"pageId" : "",
"ban" : "",
"jobId" : "",
"wrid" : "",
"jobType" : "",
"Uid" : "mbq",
"techRegion" : "",
"recordPublishIndicator" : "Y",
"__v" : 0
}