From 80186ac3d6dce4d32cb44bd530f0c68ebe594466 Mon Sep 17 00:00:00 2001 From: Sebastian Riedel Date: Tue, 27 Feb 2024 19:38:23 +0100 Subject: [PATCH] Add attention filter for product reviews --- assets/vue/ProductReviews.vue | 73 ++++++++++++++++++------------ lib/Cavil/Controller/Pagination.pm | 3 ++ lib/Cavil/Model/Packages.pm | 7 ++- 3 files changed, 52 insertions(+), 31 deletions(-) diff --git a/assets/vue/ProductReviews.vue b/assets/vue/ProductReviews.vue index e7353a76a0..5122ceb780 100644 --- a/assets/vue/ProductReviews.vue +++ b/assets/vue/ProductReviews.vue @@ -16,35 +16,47 @@  entries -
- - -
-
- - -
-
- - +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
@@ -119,6 +131,7 @@ export default { const params = getParams({ limit: 10, offset: 0, + attention: false, patent: false, trademark: false, exportRestricted: false, @@ -173,7 +186,7 @@ export default { } }, watch: { - ...genParamWatchers('limit', 'offset', 'patent', 'trademark', 'exportRestricted'), + ...genParamWatchers('limit', 'offset', 'attention', 'patent', 'trademark', 'exportRestricted'), filter: function (val) { this.params.filter = val; this.params.offset = 0; diff --git a/lib/Cavil/Controller/Pagination.pm b/lib/Cavil/Controller/Pagination.pm index 4b2de6987d..a6a412ccd5 100644 --- a/lib/Cavil/Controller/Pagination.pm +++ b/lib/Cavil/Controller/Pagination.pm @@ -67,6 +67,7 @@ sub product_reviews ($self) { my $v = $self->validation; $v->optional('limit')->num; $v->optional('offset')->num; + $v->optional('attention'); $v->optional('patent'); $v->optional('trademark'); $v->optional('exportRestricted'); @@ -74,6 +75,7 @@ sub product_reviews ($self) { return $self->reply->json_validation_error if $v->has_error; my $limit = $v->param('limit') // 10; my $offset = $v->param('offset') // 0; + my $attention = $v->param('attention') // 'false'; my $patent = $v->param('patent') // 'false'; my $trademark = $v->param('trademark') // 'false'; my $export_restricted = $v->param('exportRestricted') // 'false'; @@ -85,6 +87,7 @@ sub product_reviews ($self) { { limit => $limit, offset => $offset, + attention => $attention, patent => $patent, trademark => $trademark, export_restricted => $export_restricted, diff --git a/lib/Cavil/Model/Packages.pm b/lib/Cavil/Model/Packages.pm index 0565f9d904..000e954988 100644 --- a/lib/Cavil/Model/Packages.pm +++ b/lib/Cavil/Model/Packages.pm @@ -218,6 +218,11 @@ sub paginate_product_reviews ($self, $name, $options) { return paginate([], $options) unless my $product = $db->select('bot_products', 'id', {name => $name})->hash; + my $attention = ''; + if ($options->{attention} eq 'true') { + $attention = "AND state IN ('unacceptable', 'new')"; + } + my $search = ''; if (length($options->{search}) > 0) { my $quoted = $db->dbh->quote("\%$options->{search}\%"); @@ -245,7 +250,7 @@ sub paginate_product_reviews ($self, $name, $options) { EXTRACT(EPOCH FROM unpacked) as unpacked_epoch, EXTRACT(EPOCH FROM indexed) as indexed_epoch, state, checksum, COUNT(*) OVER() AS total FROM bot_package_products JOIN bot_packages ON (bot_packages.id = bot_package_products.package) - WHERE bot_package_products.product = ? $search $patent $trademark $export_restricted + WHERE bot_package_products.product = ? $search $attention $patent $trademark $export_restricted ORDER BY bot_packages.id DESC LIMIT ? OFFSET ? }, $product->{id}, $options->{limit}, $options->{offset}