From ea9f7b643616d9cecdb001db97ecc94bb66ee173 Mon Sep 17 00:00:00 2001 From: Kevin Puertas Ruiz Date: Fri, 20 Sep 2019 11:16:01 +0200 Subject: [PATCH] Fixes in api --- api.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/api.py b/api.py index 54f67e9..a33b95d 100644 --- a/api.py +++ b/api.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -BUILD = 18 +BUILD = 20 API_VER = 1 ##It can be run directly with "waitress-serve --port=3333 api:api" import falcon @@ -86,10 +86,10 @@ class getGroups(object): #Get local groups of a Computer ComputerID = value if ComputerID is None: - data = sql.select("SELECT * FROM GROUPS") + data = sql.select("SELECT * FROM GROUPS ORDER BY Name ASC") response.media = data else: - data = sql.select("SELECT * FROM GROUPS WHERE (SELECT ID_G FROM COMPUTER_GROUP WHERE ID_C = '"+ComputerID+"')") + data = sql.select("SELECT * FROM GROUPS WHERE ID_G IN (SELECT ID_G FROM COMPUTER_GROUP WHERE ID_C = '"+ComputerID+"') ORDER BY Name ASC") response.media = data class getComputers(object): @@ -103,10 +103,10 @@ class getComputers(object): ComputerID = value if ComputerID is None: - data = sql.select("SELECT * FROM COMPUTERS") + data = sql.select("SELECT * FROM COMPUTERS ORDER BY Name ASC") response.media = data else: - data = sql.select("SELECT * FROM COMPUTERS WHERE ID_C = '"+ComputerID+"')") + data = sql.select("SELECT * FROM COMPUTERS WHERE ID_C = '"+ComputerID+"') ORDER BY Name ASC") response.media = data @@ -181,7 +181,7 @@ class getCookPend(object): # Get the list of cooks for a computer to implement ( data.pop(x) response.media = data else: # SeeAll. Send all cooks - response.media = sql.select("SELECT DISTINCT CookName FROM COOKS_IDG WHERE ID_G IN (SELECT ID_G FROM COMPUTER_GROUP WHERE ID_C = '"+ComputerID+"')") #All cooks for this computer + response.media = sql.select("SELECT DISTINCT CookName FROM COOKS_IDG WHERE ID_G IN (SELECT ID_G FROM COMPUTER_GROUP WHERE ID_C = '"+ComputerID+"') ORDER BY CookName ASC") #All cooks for this computer ## # addCookGrp: Assign Cook to group @@ -278,7 +278,7 @@ class getCookGrp(object): GroupID = value if GroupID is not None: - result = sql.select("SELECT * FROM COOKS_IDG WHERE ID_G='"+GroupID+"'") + result = sql.select("SELECT * FROM COOKS_IDG WHERE ID_G='"+GroupID+"' ORDER BY CookName ASC") response.media = result else: response.media = {'TEXT': 'Error, no Group selected','RESULT':'ERROR'} @@ -299,7 +299,7 @@ class getGrpCook(object): # Get Groups of a Cook CookName = value if CookName is not None: - response.media = sql.select("SELECT Name FROM GROUPS WHERE ID_G IN (SELECT ID_G FROM COOKS_IDG WHERE CookName='"+CookName+"')") + response.media = sql.select("SELECT Name FROM GROUPS WHERE ID_G IN (SELECT ID_G FROM COOKS_IDG WHERE CookName='"+CookName+"') ORDER BY Name ASC") else: response.media = {'TEXT': 'Error, no Cook selected','RESULT':'ERROR'} @@ -795,11 +795,11 @@ api.add_route('/del/cleancook', delCleanCook()) #Delete status of a cook for all api.add_route('/get/computerexists', getComputerExists()) #Returns 0 or 1 (name status) api.add_route('/get/computers', getComputers()) #Get list of computer -api.add_route('/get/computersgrp', getComputersGrp()) #Get computers in a group api.add_route('/get/cookall', getCookAll()) #Get all cooks implemented in one group at least api.add_route('/get/cookgrp', getCookGrp()) # See cooks that have a determinated group api.add_route('/get/cookpend', getCookPend()) #Get cooks pending to implement to a computer api.add_route('/get/groups', getGroups()) #Get groups of a computer (Or list if not args) +api.add_route('/get/computersgrp', getComputersGrp()) #Get computers in a group api.add_route('/get/grpcook', getGrpCook()) # See groups of a determinated cook api.add_route('/get/lastrevisioncook', getLastRevisionCook()) # Returns number of last revision of a cook api.add_route('/get/statuscook', getStatusCook()) # See status of a cook