xlua: load existing CQ-WW-VHF contacts on startup

This way, restarting the logger still results in correct dup checking.

Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
1 files changed, 21 insertions(+), 9 deletions(-)

M xlua/scripts/contests/CQ-WW-VHF.lua
M xlua/scripts/contests/CQ-WW-VHF.lua +21 -9
@@ 1,5 1,5 @@ 
 --
--- Copyright (c) 2022 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+-- Copyright (c) 2022,2024 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
 --
 -- Permission is hereby granted, free of charge, to any person obtaining a copy
 -- of this software and associated documentation files (the "Software"), to deal

          
@@ 65,14 65,7 @@ local function check(band, who, mgrid, t
 	return 1 -- no prefix found ==> not dup
 end
 
-local function qso_done(qso)
-	if not ALLOWED_BANDS[qso.tx.band] then
-		return -- ignore out-of-band contacts
-	end
-
-	qso.additional['contest-id'] = 'CQ-WW-VHF'
-	qso.additional['contest-year'] = contest.year
-
+local function update_dup_table(qso)
 	local where = hash(qso.tx.grid, qso.rx.grid)
 	local mult = string.format("%u-%s", qso.tx.band, where)
 

          
@@ 84,6 77,17 @@ local function qso_done(qso)
 	mults[mult] = true
 end
 
+local function qso_done(qso)
+	if not ALLOWED_BANDS[qso.tx.band] then
+		return -- ignore out-of-band contacts
+	end
+
+	qso.additional['contest-id'] = 'CQ-WW-VHF'
+	qso.additional['contest-year'] = contest.year
+
+	update_dup_table(qso)
+end
+
 --
 -- Annunciator color
 --

          
@@ 161,6 165,14 @@ return {
 	},
 
 	events = {
+		startup = function()
+			for qso in hlog.index.history(true) do
+				if qso.additional['contest-id'] == 'CQ-WW-VHF' and
+				   qso.additional['contest-year'] == contest.year then
+					update_dup_table(qso)
+				end
+			end
+		end,
 		qso_init = function(qso)
 			contest.lcd(mkgrid(qso.tx.grid))
 		end,