def getNPS(self,NPSRaw,ordersRaw,weekPivot): NPSRaw = NPSRaw[260:] for i in range(0,len(NPSRaw)): pkOrder = BaseFunction().getColumn(ordersRaw,0) NPSRaw[i].append(ordersRaw[pkOrder.index(NPSRaw[i][0])][4]) myDict = BaseFunction().getDict(NPSRaw,weekPivot,5) allKey = BaseFunction().sortKey(myDict) NPSLunch = [10] * len(allKey) NPSDinner = [10] * len(allKey) NPSTotal = [10] * len(allKey) #first loop scan different key for i in range(0,len(allKey)): lunchCount = 0 dinnerCount = 0 #second loop scan every value in one key for j in range(0,len(myDict[allKey[i]])): temp = myDict[allKey[i]][j] if temp[4] != None: if temp[5].hour < 15: NPSLunch[i] = NPSLunch[i] + BaseFunction().getScore(temp[4]) lunchCount += 1 else: NPSDinner[i] = NPSDinner[i] + BaseFunction().getScore(temp[4]) dinnerCount += 1 NPSTotal[i] = NPSTotal[i] + BaseFunction().getScore(temp[4]) NPSLunch[i] = (NPSLunch[i]-10)*100/lunchCount NPSDinner[i] = (NPSDinner[i]-10)*100/dinnerCount NPSTotal[i] = (NPSTotal[i]-10)*100/(lunchCount+dinnerCount) return(NPSLunch,NPSDinner,NPSTotal)
def getBentoNum(self,orderDetailsRaw,ordersRaw,weekPivot): #Get all key to prepare myDict = BaseFunction().getDict(orderDetailsRaw,weekPivot,3) allKey = BaseFunction().sortKey(myDict) #create 2 lists bentoLunch = [0] * len(allKey) bentoDinner = [0] * len(allKey) status = BaseFunction().getStatus(orderDetailsRaw,ordersRaw) pkOrder = BaseFunction().getColumn(orderDetailsRaw,1) meal = BaseFunction().getMeal(BaseFunction().getColumn(orderDetailsRaw,2)) #first loop scan different key for i in range(0,len(allKey)): #second loop scan every value in one key for j in range(0,len(myDict[allKey[i]])): temp = myDict[allKey[i]][j] if status[pkOrder.index(temp[1])] == "Delivered": if meal[pkOrder.index(temp[1])] == "lunch": bentoLunch[i] += 1 else: bentoDinner[i] += 1 bentoLunch[i] = bentoLunch[i]/5 bentoDinner[i] =bentoDinner[i]/5 return(bentoLunch,bentoDinner)