Skip to content

Commit

Permalink
Fix for error 46 when editing stations
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Dec 24, 2014
1 parent da5067e commit 8af13a7
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions commands/update_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,12 @@ def validateRow(self, row):


def checkValueAgainstStats(self, widget, stats):
cr = int(widget.val.get())
minCr, avgCr, maxCr = stats
widget.configure(bg = 'white')
minCr, avgCr, maxCr = stats
if not avgCr:
return True

cr = int(widget.val.get())

if cr < int(minCr / 1.01) and cr < int(avgCr * 0.7):
widget.bell()
Expand Down Expand Up @@ -561,21 +564,29 @@ def createWidgets(self):
self.newStation = False if int(cur.fetchone()[0]) else True

cur.execute("""
SELECT item_id, MIN(price), AVG(price), MAX(price)
FROM StationBuying
WHERE station_id != ?
SELECT item.item_id,
IFNULL(MIN(price), 0),
IFNULL(AVG(price), 0),
IFNULL(MAX(price), 0)
FROM Item
LEFT OUTER JOIN StationBuying AS sb
ON (item.item_id = sb.item_id)
GROUP BY 1
""", [station.ID])
""")
self.payStats = {
ID: [ minCr, int(avgCr), maxCr ]
for ID, minCr, avgCr, maxCr in cur
}
cur.execute("""
SELECT item_id, MIN(price), AVG(price), MAX(price)
FROM StationSelling
WHERE station_id != ?
SELECT item.item_id,
IFNULL(MIN(price), 0),
IFNULL(AVG(price), 0),
IFNULL(MAX(price), 0)
FROM Item
LEFT OUTER JOIN StationSelling AS ss
ON (item.item_id = ss.item_id)
GROUP BY 1
""", [station.ID])
""")
self.askStats = {
ID: [ minCr, int(avgCr), maxCr ]
for ID, minCr, avgCr, maxCr in cur
Expand Down

0 comments on commit 8af13a7

Please sign in to comment.