Skip to content

Commit 229eb91

Browse files
authored
Merge pull request #281 from qgis/Xpirix-patch-5
Fix error sorting my plugins with latest_version_date
2 parents 404aad0 + bfccdf0 commit 229eb91

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

qgis-app/plugins/views.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,23 @@ def get_queryset(self):
11951195
# Apply the user filter
11961196
qs = self.get_filtered_queryset(qs)
11971197

1198+
qs = qs.extra(
1199+
select={
1200+
"average_vote": "rating_score / (rating_votes + 0.001)",
1201+
"latest_version_date": (
1202+
"SELECT created_on FROM plugins_pluginversion WHERE "
1203+
"plugins_pluginversion.plugin_id = plugins_plugin.id "
1204+
"AND approved = TRUE "
1205+
"ORDER BY created_on DESC LIMIT 1"
1206+
),
1207+
"weighted_rating": (
1208+
"((rating_votes::FLOAT / (rating_votes + 5)) * "
1209+
"(rating_score::FLOAT / (rating_votes + 0.001))) + "
1210+
"((5::FLOAT / (rating_votes + 5)) * 3)"
1211+
),
1212+
}
1213+
)
1214+
11981215
# Handle sorting (copied from parent class)
11991216
sort_by = self.request.GET.get("sort", None)
12001217
sort_order = self.request.GET.get("order", None)

0 commit comments

Comments
 (0)