chore: release v0.20.7
This commit is contained in:
+14
-16
@@ -1954,23 +1954,21 @@ func (r *Repo) Count(ctx context.Context) (int64, error) {
|
||||
// operator who just worked someone before (re)starting OpsLog shows online right
|
||||
// away instead of waiting for their next QSO. Empty operator matches every QSO.
|
||||
func (r *Repo) LastQSOTime(ctx context.Context, operator string) (time.Time, bool) {
|
||||
rows, err := r.db.QueryContext(ctx, `SELECT operator, qso_date FROM qso ORDER BY id DESC LIMIT 400`)
|
||||
if err != nil {
|
||||
return time.Time{}, false
|
||||
}
|
||||
defer rows.Close()
|
||||
// ONE indexed row, not 400 filtered in Go: this runs every ~5 s (the ON-AIR
|
||||
// badge) and ~15 s (live-status publish), so pulling 400 rows each time over a
|
||||
// remote MySQL hammered the connection pool and, on a busy multi-op event, was a
|
||||
// big part of "after a while nothing updates". Match the operator the same
|
||||
// (case/space-insensitive) way, newest first.
|
||||
opFilter := strings.ToUpper(strings.TrimSpace(operator))
|
||||
for rows.Next() {
|
||||
var oper, dateStr sql.NullString
|
||||
if err := rows.Scan(&oper, &dateStr); err != nil {
|
||||
return time.Time{}, false
|
||||
}
|
||||
if strings.ToUpper(strings.TrimSpace(oper.String)) != opFilter {
|
||||
continue
|
||||
}
|
||||
if t := parseTimeLoose(dateStr.String).UTC(); !t.IsZero() {
|
||||
return t, true
|
||||
}
|
||||
var dateStr sql.NullString
|
||||
err := r.db.QueryRowContext(ctx,
|
||||
`SELECT qso_date FROM qso WHERE UPPER(TRIM(operator)) = ? AND qso_date IS NOT NULL AND qso_date <> '' ORDER BY id DESC LIMIT 1`,
|
||||
opFilter).Scan(&dateStr)
|
||||
if err != nil {
|
||||
return time.Time{}, false // ErrNoRows or a real error — no known last QSO
|
||||
}
|
||||
if t := parseTimeLoose(dateStr.String).UTC(); !t.IsZero() {
|
||||
return t, true
|
||||
}
|
||||
return time.Time{}, false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user