`Updated date` sort doesn't work on Explore -> Groups

Summary

https://gitlab.com/explore/groups?sort=latest_activity_desc and https://gitlab.com/explore/groups?sort=latest_activity_asc display the same groups even though they should be in opposite sort orders.

Steps to reproduce

Go to https://gitlab.com/explore/groups?sort=latest_activity_desc and https://gitlab.com/explore/groups?sort=latest_activity_asc. They display the same groups.

What is the current bug behavior?

Updated date sort doesn't work

What is the expected correct behavior?

Updated date sort should sort in correct order

Possible fixes

We're currently not supporting group sorting based on latest_activity_desc and/or latest_activity_asc. The reason is that our groups do not have the last_activity_at attribute.

One approach to address this limitation is to create two new scopes at the group level, such as sorted_by_updated_asc and sorted_by_updated_desc. We can then identify the project with the maximum last_activity_at value per group and sort the groups accordingly. Essentially, this would involve sorting groups based on the most recent activity of their associated projects.

Edited by Christina Lohr