Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
miladbarooni committed Jan 24, 2020
2 parents 9904552 + d5274ee commit ed607d1
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions snapFood.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,15 @@ def charging(self, user_id, amount): #NOT CHECKED
self._mycursor.execute("UPDATE WALLET SET balance = %s WHERE walletid = %s;", (str(balance + amount), str(wallet_id),))
self._mydb.commit()

def adminLogin(self, username): #NOT CHECKED
def calculateRate(self, shop_id):
self._mycursor.execute("""SELECT Avg(rate) FROM
(((SHOP JOIN FOOD ON SHOPshopid = shopid)
JOIN FOOD_INVOIC on FOODfoodid = foodid)
JOIN INVOIC ON INVOICinvoiceid = invoiceid)
JOIN COMMENT ON COMMENTcommentid = commentid WHERE shopid = %s""",(str(shop_id),))
return self._mycursor.fetchall()

def adminLogin(self, username):
self._mycursor.execute("SELECT * FROM ADMIN WHERE username = %s", (str(username),))
return self._mycursor.fetchall()

Expand Down Expand Up @@ -428,19 +436,39 @@ def showActiveOrder(self, shop_id):
"""
invoiceid, total-price, ADDRESSaddressid, FOODfoodid, STATUS.name
"""
self._mycursor.execute("""SELECT invoiceid, `total-price`, ADDESSaddressid, FOODfoodid, STATUS.name FROM
self._mycursor.execute("""SELECT invoiceid, `total-price`, INVOIC.ADDRESSaddressid, FOODfoodid, STATUS.name FROM
(((SHOP JOIN FOOD ON SHOPshopid = shopid)
JOIN `FOOD_INVOIC` ON FOODfoodid = foodid)
JOIN INVOIC ON INVOICinvoiceid = invoiceid)
JOIN STATUS ON STATUSstatusid = statusid WHERE shopid = %s AND STATUS.name <> \'Completed\';""", (str(shop_id),))
return self._mycursor.fetchall()

def showShopHistory(self, shop_id):
"""
invoiceid, total-price, ADDRESSaddressid, FOODfoodid, STATUS.name
"""
self._mycursor.execute("""SELECT invoiceid, `total-price`, INVOIC.ADDRESSaddressid, FOODfoodid, STATUS.name FROM
(((SHOP JOIN FOOD ON SHOPshopid = shopid)
JOIN `FOOD_INVOIC` ON FOODfoodid = foodid)
JOIN INVOIC ON INVOICinvoiceid = invoiceid)
JOIN STATUS ON STATUSstatusid = statusid WHERE shopid = %s AND STATUS.name = \'Completed\';""", (str(shop_id),))
return self._mycursor.fetchall()

def showAllComments(self, shop_id):
self._mycursor.execute("""SELECT invoiceid, `total-price`, INVOIC.ADDRESSaddressid, FOODfoodid, COMMENT.text, COMMENT.rate FROM
(((SHOP JOIN FOOD ON SHOPshopid = shopid)
JOIN `FOOD_INVOIC ON FOODfoodid = foodid)
JOIN `FOOD_INVOIC` ON FOODfoodid = foodid)
JOIN INVOIC ON INVOICinvoiceid = invoiceid)
JOIN STATUS ON STATUSstatusid = statusid WHERE shopid = %s AND STATUS.name != \'Complete""", (str(shop_id),))
JOIN COMMENT ON COMMENTcommentid = commentid WHERE shopid = %s;""", (str(shop_id),))
return self._mycursor.fetchall()

def temp(self):
self._mycursor.execute("UPDATE STATUS SET name = \'Prepration\' WHERE statusid = 7;")
#self._mycursor.execute("UPDATE STATUS SET name = \'Prepration\' WHERE statusid = 7;")
self._mydb.commit()

def close(self):
self._mydb.close()

db = SnapFoodDB()
print(db.temp())
print(db.showAllComments(3))
db.close()

0 comments on commit ed607d1

Please sign in to comment.