Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions monitoring/db_update_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,16 @@ def refresh_gridsitesync_submithost():
site = record.get("Site")
month = record.get("Month")
year = record.get("Year")
submit_host = record.get("SubmitHostSumm") or record.get("SubmitHostSync")
record_start = record.get("RecordStart")
# Use SubmitHostSync when SubmitHostSumm is missing (NaN)
submit_host = (
record.get("SubmitHostSync")
if pd.isna(record.get("SubmitHostSumm"))
else record.get("SubmitHostSumm")
Comment thread
tofu-rocketry marked this conversation as resolved.
)
record_start = none_if_missing(record.get("RecordStart"))
record_end = none_if_missing(record.get("RecordEnd"))
Comment thread
tofu-rocketry marked this conversation as resolved.

# Skip rows where RecordStart is missing or NaN
if pd.isna(record_start):
if pd.isna(submit_host):
continue

# Sanitize numeric fields
Expand All @@ -516,7 +521,7 @@ def refresh_gridsitesync_submithost():
SubmitHost=submit_host,
defaults={
'RecordStart': record_start,
'RecordEnd': record.get("RecordEnd"),
'RecordEnd': record_end,
'RecordCountPublished': record_count_published,
'RecordCountInDb': record_count_in_db,
}
Expand All @@ -528,6 +533,13 @@ def refresh_gridsitesync_submithost():
log.exception("Error while trying to refresh GridSiteSyncSubmitH")


def none_if_missing(value):
Comment thread
tofu-rocketry marked this conversation as resolved.
"""
Return None when the value is missing (NaN/NaT), otherwise return it unchanged.
"""
return None if pd.isna(value) else value


if __name__ == "__main__":
log.info('=====================')

Expand Down
4 changes: 2 additions & 2 deletions monitoring/publishing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class GridSiteSyncSubmitH(models.Model):
YearMonth = models.CharField(max_length=255)
Year = models.IntegerField()
Month = models.IntegerField()
RecordStart = models.DateTimeField()
RecordEnd = models.DateTimeField()
RecordStart = models.DateTimeField(null=True)
RecordEnd = models.DateTimeField(null=True)
RecordCountPublished = models.IntegerField()
RecordCountInDb = models.IntegerField()
SubmitHost = models.CharField(max_length=255)
Expand Down
4 changes: 2 additions & 2 deletions monitoring/publishing/templates/gridsync_submithost.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ <h3>APEL Synchronisation Test</h3>
<tr onmouseover="this.className='highlight-row'" onmouseout="this.className='tabletext'" class="tabletext">
<td>{{ host.YearMonth }} </td>
<td>{{ host.SubmitHost }}</td>
<td>{{ host.RecordStart }}</td>
<td>{{ host.RecordEnd }}</td>
<td>{{ host.RecordStart|default:"n/a" }}</td>
<td>{{ host.RecordEnd|default:"n/a" }}</td>
<td>{{ host.RecordCountInDb|intcomma }}</td>
<td>{{ host.RecordCountPublished|intcomma }}</td>
</tr>
Expand Down