Skip to content

Commit

Permalink
fix issue with large --ly distance returning too many systems to filt…
Browse files Browse the repository at this point in the history
…er by
  • Loading branch information
tKe committed Jan 11, 2015
1 parent 174e376 commit 0233174
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions commands/buy_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,21 @@ def run(results, cmdenv, tdb):
includeSelf=True,
)
}
tables += (
" INNER JOIN Station AS stn"
" ON (stn.station_id = ss.station_id)"
)
constraints.append("(stn.system_id IN ({}))".format(
",".join(['?'] * len(systemRanges))
))
bindValues += list(system.ID for system in systemRanges.keys())
# We need to ensure we use less than 999 bind values in total.
# If we don't filter in the query, we'll filter by stations in
# systemRanges when building our result rows
if len(systemRanges) > 999-len(bindValues):
cmdenv.DEBUG0("Too many matching systems ({}) for SQL filter. "
"Hard way it is.".format(len(systemRanges)))
else:
tables += (
" INNER JOIN Station AS stn"
" ON (stn.station_id = ss.station_id)"
)
constraints.append("(stn.system_id IN ({}))".format(
",".join(['?'] * len(systemRanges))
))
bindValues += list(system.ID for system in systemRanges.keys())

whereClause = ' AND '.join(constraints)
stmt = """
Expand All @@ -140,7 +147,10 @@ def run(results, cmdenv, tdb):
row = ResultRow()
row.station = station
if nearSystem:
row.dist = systemRanges[row.station.system]
# check the system was in our range query
if row.station.system not in systemRanges:
continue
row.dist = systemRanges[row.station.system]
row.price = priceCr
row.stock = stock
row.age = age
Expand Down

0 comments on commit 0233174

Please sign in to comment.