Chapter 2: Basic Aggregation - Utility Stages - Submit issue

Chapter 2: Basic Aggregation - Utility Stages

Lab - Bringing it all together

Unable to submit lab

What error you are getting?
Did you miss the deadline
They are weekly based
On course page you can see start date and due date
Also check overview page

yes i missed the deadline

@Memosha_53183

As the course documents clearly state, submissions are not accepted after the deadline of 17:00 GMT on Tuesday. Any work not completed and submitted by the deadline is considered “Failed”. Better luck this week.

Hello. I am not sure but probably the sample dataset was updated in the aggregations-db. Or how may you explain that magic? I am sure that I haven’t changed data in the collection.

MongoDB Enterprise Cluster0-shard-0:PRIMARY>var favorites = [
  "Sandra Bullock",
  "Tom Hanks",
  "Julia Roberts",
  "Kevin Spacey",
  "George Clooney"]
var pipeline = [
     {   $match:
 {          cast: {            $in: favorites},
		"countries":"USA"        }   },

  {    $project: {
	num_favs: {            $size: {
		$setIntersection: [favorites , "$cast"]     }},
	"tomatoes.viewer.rating": 1,	
	title: 1  } },

 {$sort:{num_favs:-1, "tomatoes.viewer.rating":-1, title:-1}},

 {$skip:24}]
MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.movies.aggregate(pipeline).pretty()
{
        "_id" : ObjectId("573a13b2f29313caabd39eef"),
        "title" : "Fantastic Mr. Fox",
        "tomatoes" : {
                "viewer" : {
                        "rating" : 3.9
                }
        },
        "num_favs" : 1
}
{
        "_id" : ObjectId("573a13ddf29313caabdb320f"),
        "title" : "The Heat",
        "tomatoes" : {
                "viewer" : {
                        "rating" : 3.8
                }
        },
        "num_favs" : 1
}
{
        "_id" : ObjectId("573a13bdf29313caabd5a39c"),
        "title" : "The Descendants",
        "tomatoes" : {
                "viewer" : {
                        "rating" : 3.8
                }
        },
        "num_favs" : 1
}

It is hard to say because you do not share with us the value of the variable favorites.

Is there any reason why you do not use it, the variable favorites, in the $match stage?

Yeah, I forgot to attach the value of favorites. I added it now. May you investigate the code again, please?

Actually, I get the right answer when I use the piepeline from the detailed answer.

Your aggregation is missing the requirement:

tomatoes.viewer.rating greater than or equal to 3

1 Like