Preview:
[
    {
        "$match": {
            "userStatus": "ACTIVE",
            "partnerShortCode": {
                "$in": [
                    "CHC",
                    "DRB",
                    "DRL",
                    "DUMMY",
                    "GLOBANT",
                    "IHL",
                    "JIVA",
                    "MINDTREE",
                    "MM",
                    "SHUDDHI",
                    "SMITFIT",
                    "SUDLIFE",
                    "test201",
                    "wipro"
                ]
            }
        }
    },
    {
        "$lookup": {
            "from": "generatedparticipantdata",
            "localField": "email",
            "foreignField": "email",
            "as": "generatedParticipantDataLookupLkp"
        }
    },
    {
        "$unwind": {
            "path": "$generatedParticipantDataLookupLkp",
            "preserveNullAndEmptyArrays": true
        }
    },
    {
        "$match": {}
    },
    {
        "$lookup": {
            "from": "subscription",
            "localField": "_id",
            "foreignField": "userId",
            "as": "subscriptionLkp"
        }
    },
    {
        "$project": {
            "subscriptionLkp": {
                "$arrayElemAt": [
                    {
                        "$filter": {
                            "input": "$subscriptionLkp",
                            "as": "subscription",
                            "cond": {
                                "$eq": [
                                    "$$subscription.active",
                                    true
                                ]
                            }
                        }
                    },
                    0
                ]
            },
            "partnerShortCode": 1,
            "firstName": 1,
            "_id": 1,
            "middleName": 1,
            "lastName": 1,
            "email": 1,
            "mobile": 1,
            "source": 1,
            "lastAppLaunchDate": "$userLkp.lastAppLaunchDate",
            "daysSpentOnApp": 1,
            "bmi": "$generatedParticipantDataLookupLkp.bmi",
            "profilePictureURL": 1,
            "startDate":{
                            "$arrayElemAt": [
                                "$subscriptionLkp.startDate",
                                0
                            ]
                        },
            "journeyDays": {
                "$dateDiff": {
                    "startDate": {
                        "$toDate": {
                            "$arrayElemAt": [
                                "$subscriptionLkp.startDate",
                                0
                            ]
                        }
                    },
                    "endDate": {
                        "$date": "2024-05-21T04:04:07.418Z"
                    },
                    "unit": "day"
                }
            }
        }
    },
    {
        "$unwind": {
            "path": "$subscriptionLkp",
            "preserveNullAndEmptyArrays": true
        }
    },
    {
        "$lookup": {
            "from": "subscriptionPlan",
            "localField": "subscriptionLkp.planId",
            "foreignField": "_id",
            "as": "subscriptionPlanLkp"
        }
    },
    {
        "$unwind": {
            "path": "$subscriptionPlanLkp",
            "preserveNullAndEmptyArrays": true
        }
    },
    {
        "$match": {}
    },
    {
        "$match": {
            "journeyDays": {
                "$gte": 200,
                "$lte": 300
            }
        }
    },
    {
        "$lookup": {
            "from": "users",
            "localField": "email",
            "foreignField": "email",
            "as": "userLkp"
        }
    },
    {
        "$unwind": {
            "path": "$userLkp",
            "preserveNullAndEmptyArrays": true
        }
    },
    {
        "$sort": {
            "_id": -1
        }
    },
    {
        "$project": {
            "name": "$subscriptionPlanLkp.name",
            "partnerShortCode": 1,
            "firstName": 1,
            "middleName": 1,
            "lastName": 1,
            "email": 1,
            "mobile": 1,
            "source": 1,
            "lastAppLaunchDate": "$userLkp.lastAppLaunchDate",
            "daysSpentOnApp": 1,
            "bmi": 1,
            "profilePictureURL": 1,
            "servicePartnerShortCode": "$userLkp.servicePartnerShortCode",
            "userVisibility": "$userLkp.userVisibility",
            "journeyDays": 1,
            "startDate":1
        }
    }
]
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter