Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions qgis-app/plugins/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,23 @@ def get_queryset(self):
# Apply the user filter
qs = self.get_filtered_queryset(qs)

qs = qs.extra(
select={
"average_vote": "rating_score / (rating_votes + 0.001)",
"latest_version_date": (
"SELECT created_on FROM plugins_pluginversion WHERE "
"plugins_pluginversion.plugin_id = plugins_plugin.id "
"AND approved = TRUE "
"ORDER BY created_on DESC LIMIT 1"
),
"weighted_rating": (
"((rating_votes::FLOAT / (rating_votes + 5)) * "
"(rating_score::FLOAT / (rating_votes + 0.001))) + "
"((5::FLOAT / (rating_votes + 5)) * 3)"
),
}
)

# Handle sorting (copied from parent class)
sort_by = self.request.GET.get("sort", None)
sort_order = self.request.GET.get("order", None)
Expand Down
Loading