Skip to content

Commit bfccdf0

Browse files
committed
Enhance MyPluginsList queryset to include average vote and latest version date calculations
1 parent f85f05c commit bfccdf0

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

qgis-app/plugins/views.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,10 +1191,27 @@ class MyPluginsList(PluginsList):
11911191
def get_queryset(self):
11921192
"""Override to include soft-deleted plugins for the user's own plugins."""
11931193
# Use objects.all() to bypass the BasePluginManager filter that excludes soft-deleted items
1194-
qs = Plugin.base_objects.all()
1194+
qs = Plugin.objects.all()
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)