Skip to content

Commit 5a45cd6

Browse files
committed
Ensure scan has scanned at value
1 parent a6a6871 commit 5a45cd6

1 file changed

Lines changed: 31 additions & 30 deletions

File tree

src/load.py

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,37 +1495,38 @@ def get_bodies_summary(bodies: dict[str, PlanetData], focused: bool = False) ->
14951495
if not scan or scan[0].count < 3:
14961496
complete = False
14971497
else:
1498-
next_death = this.sql_session.scalar(select(Death).where(Death.commander_id == this.commander.id)
1499-
.where(Death.died_at > scan[0].scanned_at)
1500-
.order_by(asc(Death.died_at)))
1501-
next_resurrection = this.sql_session.scalar(select(Resurrection).where(Resurrection.commander_id == this.commander.id)
1502-
.where(Resurrection.type.in_(['escape', 'recover', 'rejoin']))
1503-
.where(Resurrection.resurrected_at > scan[0].scanned_at)
1504-
.order_by(asc(Resurrection.resurrected_at)))
1505-
lost_date = None
1506-
if next_death and next_resurrection:
1507-
lost_date = next_death.died_at if next_death.died_at < next_resurrection.resurrected_at else next_resurrection.resurrected_at
1508-
elif next_death:
1509-
lost_date = next_death.died_at
1510-
elif next_resurrection:
1511-
lost_date = next_resurrection.resurrected_at
1512-
if lost_date:
1513-
sale = this.sql_session.scalar(
1514-
select(ExoBioSale).where(ExoBioSale.commander_id == this.commander.id)
1515-
.where(ExoBioSale.sold_at > scan[0].scanned_at).where(ExoBioSale.sold_at < lost_date))
1516-
if sale:
1517-
num_complete += 1
1518-
was_sold = True
1498+
if scan[0].scanned_at:
1499+
next_death = this.sql_session.scalar(select(Death).where(Death.commander_id == this.commander.id)
1500+
.where(Death.died_at > scan[0].scanned_at)
1501+
.order_by(asc(Death.died_at)))
1502+
next_resurrection = this.sql_session.scalar(select(Resurrection).where(Resurrection.commander_id == this.commander.id)
1503+
.where(Resurrection.type.in_(['escape', 'recover', 'rejoin']))
1504+
.where(Resurrection.resurrected_at > scan[0].scanned_at)
1505+
.order_by(asc(Resurrection.resurrected_at)))
1506+
lost_date = None
1507+
if next_death and next_resurrection:
1508+
lost_date = next_death.died_at if next_death.died_at < next_resurrection.resurrected_at else next_resurrection.resurrected_at
1509+
elif next_death:
1510+
lost_date = next_death.died_at
1511+
elif next_resurrection:
1512+
lost_date = next_resurrection.resurrected_at
1513+
if lost_date:
1514+
sale = this.sql_session.scalar(
1515+
select(ExoBioSale).where(ExoBioSale.commander_id == this.commander.id)
1516+
.where(ExoBioSale.sold_at > scan[0].scanned_at).where(ExoBioSale.sold_at < lost_date))
1517+
if sale:
1518+
num_complete += 1
1519+
was_sold = True
1520+
else:
1521+
complete = False
1522+
was_lost = True
15191523
else:
1520-
complete = False
1521-
was_lost = True
1522-
else:
1523-
num_complete += 1
1524-
sale = this.sql_session.scalar(
1525-
select(ExoBioSale).where(ExoBioSale.commander_id == this.commander.id)
1526-
.where(ExoBioSale.sold_at > scan[0].scanned_at))
1527-
if sale:
1528-
was_sold = True
1524+
num_complete += 1
1525+
sale = this.sql_session.scalar(
1526+
select(ExoBioSale).where(ExoBioSale.commander_id == this.commander.id)
1527+
.where(ExoBioSale.sold_at > scan[0].scanned_at))
1528+
if sale:
1529+
was_sold = True
15291530
flora_status[flora.id] = (was_sold, was_lost)
15301531
else:
15311532
complete = False

0 commit comments

Comments
 (0)