Skip to content

Commit 9e261ba

Browse files
committed
fix: changes based on PR feedback
1 parent be76fa8 commit 9e261ba

4 files changed

Lines changed: 27 additions & 12 deletions

File tree

static/sass/styles.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ dl {
277277
}
278278
}
279279

280-
281280
.snap-published-in-cell {
282281
@media (max-width: $breakpoint-large - 1) {
283282
display: none !important;

templates/store/snap-details/_details.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,16 @@ <h3 class="p-muted-heading">Last updated</h3>
1616
<li>{{ updates[1]["released-at-display"] }} - <small>{{ updates[1]["track"] }}/{{ updates[1]["risk"] }}</small></li>
1717
{% endif %}
1818
</ul>
19-
<hr class="p-rule--muted">
20-
{% endif %}
21-
22-
{% if old_snap_info and old_snap_info.is_old %}
19+
{% if old_snap_info and old_snap_info.is_old %}
2320
<div class="p-notification--caution is-borderless">
2421
<div class="p-notification__content">
2522
<p class="p-notification__message">
26-
This snap in this channel hasn't been updated since {{ old_snap_info.last_updated_formatted }}. Contact the developer to ask for an update.
23+
This snap hasn't been updated since {{ old_snap_info.last_updated_formatted }}. It might be unmaintained and have stability or security issues.
2724
</p>
2825
</div>
2926
</div>
30-
<hr>
27+
{% endif %}
28+
<hr class="p-rule--muted">
3129
{% endif %}
3230

3331
{% if links %}

webapp/store/logic.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import humanize
77
from dateutil import parser
8+
from dateutil.relativedelta import relativedelta
89
from webapp import helpers
910

1011

@@ -245,11 +246,10 @@ def is_snap_old(last_updated_date, old_threshold_years=2.0):
245246

246247
now = datetime.datetime.now(datetime.timezone.utc)
247248

248-
days_diff = (now - date_parsed).days
249-
years_diff = days_diff / 365.25 # Account for leap years
250-
years_since_update = int(years_diff)
249+
delta = relativedelta(now, date_parsed)
250+
years_since_update = delta.years
251251

252-
is_old = days_diff >= (old_threshold_years * 365.25)
252+
is_old = years_since_update >= old_threshold_years
253253

254254
return {
255255
"is_old": is_old,

webapp/store/snap_details_views.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,24 @@ def _get_context_snap_details(snap_name, supported_architectures=None):
106106
lowest_risk_available,
107107
supported_architectures,
108108
)
109+
110+
# Determine the most recent update date from updates tuple
111+
# updates[0] is the stable channel, updates[1] is the most
112+
# recent non-stable
113+
most_recent_update = None
114+
if updates[0] and updates[1]:
115+
# Compare both and use the most recent
116+
date_0 = updates[0].get("released-at")
117+
date_1 = updates[1].get("released-at")
118+
if date_0 and date_1:
119+
most_recent_update = max(date_0, date_1)
120+
else:
121+
most_recent_update = date_0 or date_1
122+
elif updates[0]:
123+
most_recent_update = updates[0].get("released-at")
124+
elif updates[1]:
125+
most_recent_update = updates[1].get("released-at")
126+
109127
binary_filesize = latest_channel["download"]["size"]
110128

111129
# filter out banner and banner-icon images from screenshots
@@ -191,7 +209,7 @@ def _get_context_snap_details(snap_name, supported_architectures=None):
191209
"filesize": humanize.naturalsize(binary_filesize),
192210
"last_updated": logic.convert_date(last_updated),
193211
"last_updated_raw": last_updated,
194-
"old_snap_info": logic.is_snap_old(last_updated),
212+
"old_snap_info": logic.is_snap_old(most_recent_update),
195213
"is_users_snap": is_users_snap,
196214
"unlisted": details.get("snap", {}).get("unlisted", False),
197215
"developer": developer,

0 commit comments

Comments
 (0)