mischief: tighten the detail page's live poll and drop dead state
The who-page poll now keeps the location line honest both ways (a mark that came back to town stops showing its old expedition) and stops polling once the adventurer leaves the board. Also collapses a redundant branch in ResolveMischiefOrder and removes the always-false whoPage.Stale.
This commit is contained in:
@@ -117,18 +117,17 @@ func ResolveMischiefOrder(guid, status, detail string) (MischiefOrder, error) {
|
||||
return MischiefOrder{}, fmt.Errorf("mischief: bad verdict %q", status)
|
||||
}
|
||||
now := nowUnix()
|
||||
res, err := Get().Exec(
|
||||
if _, err := Get().Exec(
|
||||
`UPDATE mischief_orders SET status = ?, detail = ?, updated_at = ?
|
||||
WHERE guid = ? AND status = ?`,
|
||||
status, detail, now, guid, MischiefPending,
|
||||
)
|
||||
if err != nil {
|
||||
); err != nil {
|
||||
return MischiefOrder{}, fmt.Errorf("mischief: resolve order: %w", err)
|
||||
}
|
||||
if n, _ := res.RowsAffected(); n == 0 {
|
||||
// Either it doesn't exist or it's already terminal. Tell the caller which.
|
||||
return MischiefOrderByGUID(guid)
|
||||
}
|
||||
// Whether the update moved a pending order or matched nothing (missing, or
|
||||
// already terminal from an earlier verdict), the current row is the
|
||||
// authoritative answer — reading it back is the single path either way, and
|
||||
// MischiefOrderByGUID turns a missing row into ErrNoSuchOrder for the caller.
|
||||
return MischiefOrderByGUID(guid)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user