@@ -195,7 +195,15 @@ get_notifs() {
195
195
def colored(text; color):
196
196
colors[color] + text + colors.reset;
197
197
.[] | {
198
- updated_short: .updated_at | fromdateiso8601 | strftime("%Y-%m"),
198
+ updated_short:
199
+ # for some reason ".updated_at" can be null
200
+ if .updated_at then
201
+ .updated_at | fromdateiso8601 | strftime("%Y-%m")
202
+ else
203
+ # Github Discussion launched in 2020
204
+ # https://resources.github.com/devops/process/planning/discussions/
205
+ "2020"
206
+ end,
199
207
# UTC time ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
200
208
# https://docs.github.com/en/rest/overview/resources-in-the-rest-api#timezones
201
209
iso8601: now | strftime("%Y-%m-%dT%H:%M:%SZ"),
@@ -205,15 +213,21 @@ get_notifs() {
205
213
repo_full_name: .repository.full_name,
206
214
unread_symbol: colored((if .unread then "\u25cf" else "\u00a0" end); "magenta"),
207
215
# make sure each outcome has an equal number of fields separated by spaces
208
- timefmt: colored(((if .unread then .last_read_at // .updated_at else .updated_at end) | fromdateiso8601) as $time_sec |
209
- # difference is less than one hour
210
- if ((now - $time_sec) / 3600) < 1 then
211
- (now - $time_sec) / 60 | floor | tostring + "min ago"
212
- # difference is less than 24 hours
213
- elif ((now - $time_sec) / 3600) < 24 then
214
- (now - $time_sec) / 3600 | floor | tostring + "h ago"
216
+ timefmt: colored(
217
+ # for some reason ".updated_at" can be null
218
+ if (.unread and .last_read_at) or .updated_at then
219
+ ((if .unread then .last_read_at // .updated_at else .updated_at end) | fromdateiso8601) as $time_sec |
220
+ # difference is less than one hour
221
+ if ((now - $time_sec) / 3600) < 1 then
222
+ (now - $time_sec) / 60 | floor | tostring + "min ago"
223
+ # difference is less than 24 hours
224
+ elif ((now - $time_sec) / 3600) < 24 then
225
+ (now - $time_sec) / 3600 | floor | tostring + "h ago"
226
+ else
227
+ $time_sec | strflocaltime("%d/%b %H:%M")
228
+ end
215
229
else
216
- $time_sec | strflocaltime("%d/%b %H:%M")
230
+ "Not available"
217
231
end; "gray"),
218
232
owner_abbreviated: colored(
219
233
if (.repository.owner.login | length) > 10 then
0 commit comments