[gnome-software/1647-show-the-newest-review-in-app-details-page] gs-details-page: Pick featured review within the last 6 months
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1647-show-the-newest-review-in-app-details-page] gs-details-page: Pick featured review within the last 6 months
- Date: Wed, 16 Feb 2022 14:58:21 +0000 (UTC)
commit a18fed603daa87d4f36778254df6354886357d98
Author: Milan Crha <mcrha redhat com>
Date: Wed Feb 16 15:56:21 2022 +0100
gs-details-page: Pick featured review within the last 6 months
Rather than showing years old review as the featured review, consider
only reviews not older than 6 months.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1647
src/gs-details-page.c | 9 +++++++++
1 file changed, 9 insertions(+)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 2bc5b673a..02fcee94b 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1245,10 +1245,15 @@ static AsReview *
get_featured_review (GPtrArray *reviews)
{
AsReview *featured;
+ g_autoptr(GDateTime) now_utc = NULL;
+ g_autoptr(GDateTime) min_date = NULL;
gint featured_priority;
g_assert (reviews->len > 0);
+ now_utc = g_date_time_new_now_utc ();
+ min_date = g_date_time_add_months (now_utc, -6);
+
featured = g_ptr_array_index (reviews, 0);
featured_priority = as_review_get_priority (featured);
@@ -1256,6 +1261,10 @@ get_featured_review (GPtrArray *reviews)
AsReview *new = g_ptr_array_index (reviews, i);
gint new_priority = as_review_get_priority (new);
+ /* Skip reviews older than 6 months for the featured pick */
+ if (g_date_time_compare (as_review_get_date (new), min_date) < 0)
+ continue;
+
if (featured_priority > new_priority ||
(featured_priority == new_priority &&
g_date_time_compare (as_review_get_date (featured), as_review_get_date (new)) > 0)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]