fix(lotw): precise uploaded marking; surface skipped/unavailable counts

P2 — markUploaded now only marks the records that actually made it
into the accepted TQ8 batch (preview.submittedIds), never the whole
candidate list. Previously, un-signable records skipped by prepare()
were still marked UP after any accepted upload, falsely showing them
as uploaded.

P4 — surface why records did not upload:
- When audit finds nothing pending, distinguish unavailable records
  (invalid call/date — check logbook) from unknown-result records
  (not retried automatically) instead of a blanket 'no pending'.
- Upload preview dialogs (Log tab + logbook) show a breakdown line:
  N already uploaded/duplicate · N unknown result · N un-uploadable.
This commit is contained in:
atsunatsu committed 2026-09-27 17:46:21 +08:00
1 parent fe85703e56
commit 1dd185971f
6 files changed
+45 -7

No files matched your search

@@ -196,6 +196,7 @@ class LoTWUploadRepository internal constructor(
val ledger = ledger()
var skipped = 0
var unknown = 0
var unavailable = 0
val unique = hashSetOf<String>()
val contacts = records.sortedBy { it.startUtcMillis }.mapNotNull { record ->
coroutineContext.ensureActive()
@@ -205,7 +206,7 @@ class LoTWUploadRepository internal constructor(
} catch (_: LoTWOperationException) {
// One un-signable record must not abort the whole batch:
// skip it, count it, and let the rest upload.
skipped++
unavailable++
return@mapNotNull null
}
val previous = ledger[contact.fingerprint]
@@ -221,7 +222,9 @@ class LoTWUploadRepository internal constructor(
contacts.firstOrNull()?.record?.let { utc(it.startUtcMillis, "yyyy-MM-dd HH:mm:ss") }.orEmpty(),
contacts.lastOrNull()?.record?.let { utc(it.startUtcMillis, "yyyy-MM-dd HH:mm:ss") }.orEmpty(),
contacts.map { "${utc(it.record.startUtcMillis, "MM-dd HH:mm")} ${it.record.theirCallsign} ${it.fields["MODE"]} ${it.fields["SAT_NAME"].orEmpty()}" },
unknown
unknown,
unavailable,
contacts.map { it.record.id }
)
if (contacts.isNotEmpty()) pending = Pending(
preview,
@@ -66,7 +66,12 @@ data class LoTWUploadPreview(
val firstUtc: String,
val lastUtc: String,
val contacts: List<String>,
val unknownSkipped: Int = 0
val unknownSkipped: Int = 0,
/** Un-signable records (invalid call/date/…) skipped instead of aborting the batch. */
val unavailableSkipped: Int = 0,
/** Ids of the records that actually made it into this TQ8 batch. Only these
* may be marked "uploaded" after an accepted POST — never the full candidate list. */
val submittedIds: List<Long> = emptyList()
)
/** Local comparison against downloaded LoTW receipt flags and this app's durable upload receipts. */