Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/journal_client.py
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | for msg_dict in interesting_messages: | ||||
else: | else: | ||||
# same snapshot as before | # same snapshot as before | ||||
if ( | if ( | ||||
latest_recorded_visit_date | latest_recorded_visit_date | ||||
and current_status_date < latest_recorded_visit_date | and current_status_date < latest_recorded_visit_date | ||||
): | ): | ||||
# we receive an old message which is an earlier "eventful" event | # we receive an old message which is an earlier "eventful" event | ||||
# than what we had, we consider the last_eventful event as | # than what we had, we consider the last_eventful event as | ||||
# actually an uneventful event. The true eventful message is the | # actually an uneventful event. | ||||
# current one | # The last uneventful visit remains the most recent: | ||||
visit_stats_d["last_uneventful"] = visit_stats_d[ | # max, previously computed | ||||
"last_eventful" | visit_stats_d["last_uneventful"] = latest_recorded_visit_date | ||||
] | # The eventful visit remains the oldest one: min | ||||
visit_stats_d["last_eventful"] = current_status_date | visit_stats_d["last_eventful"] = min( | ||||
visit_stats_d["last_eventful"], current_status_date | |||||
) | |||||
elif ( | elif ( | ||||
latest_recorded_visit_date | latest_recorded_visit_date | ||||
and current_status_date == latest_recorded_visit_date | and current_status_date == latest_recorded_visit_date | ||||
): | ): | ||||
# A duplicated message must be ignored to avoid | # A duplicated message must be ignored to avoid | ||||
# populating the last_uneventful message | # populating the last_uneventful message | ||||
continue | continue | ||||
else: | else: | ||||
# uneventful event | # uneventful event | ||||
visit_stats_d["last_uneventful"] = current_status_date | visit_stats_d["last_uneventful"] = current_status_date | ||||
scheduler.origin_visit_stats_upsert( | scheduler.origin_visit_stats_upsert( | ||||
OriginVisitStats(**ovs) for ovs in origin_visit_stats.values() | OriginVisitStats(**ovs) for ovs in origin_visit_stats.values() | ||||
) | ) |