Ecto Query Check

I have users who sign in to classes as part of a course. I’d like to return a list of the top 5 users with the highest attendance, along with their attendance count, in the last 90 days.

I came up with the following, but was wondering if it is the ‘best’ way to do this in Ecto? I thought it might be quicker with a second query to preload users rather than a join but wasn’t able to figure out how to do it that way.

      from s in Signin,
      join: u in User, where: s.user_id ==,
      where: s.class_date > datetime_add(^Ecto.DateTime.utc, -90, "day") and
            s.course_id == ^,
      group_by: [s.user_id,],
      order_by: [desc: count(s.user_id)],
      limit: 5,
      select: %{user: u, count: count(s.user_id)}

Just as an aside, why the first 5? I could easily see well more than 5 students having never missed a day? How do you determine which of those to choose as the top 5?