Skip to content
Snippets Groups Projects
Commit b716f1ab authored by erichard's avatar erichard
Browse files

Move function outside the routes module.

parent 7385dc01
No related branches found
No related tags found
2 merge requests!61Packager labelstower,!60WIP: Implement sqlalchemy
......@@ -192,6 +192,23 @@ def get_ids(objects: List[Dict[int, str]]) -> str :
#remove last extra comma
return objects_ids[0:-1]
def get_user_selection(number_of_mandatory_labels: int, optional1: str, optional2: str) -> tuple :
'''
Return the right values of id_mandatory_labels and id_forbiden_labels when optional2 is missing.
It is necessary because optional1 could be id_mandatory_labels or id_forbiden_labels.
:param number_of_mandatory_labels: int
:param optional1: str
:param optional2: str
:return:
'''
if int(number_of_mandatory_labels):
id_mandatory_labels = optional1
id_forbiden_labels = optional2
else:
id_mandatory_labels = optional2
id_forbiden_labels = optional1
return id_mandatory_labels, id_forbiden_labels
def send_query_to_db(query: str) -> List[Dict[int, str]] :
'''
Return the result of the query send to the database
......
from typing import Dict, List
import json
from app.labels_system.getter import get_selected_elements, get_discriminating_labels, get_high_discriminating_labels
from app.labels_system.getter import get_selected_elements, get_discriminating_labels, get_high_discriminating_labels, get_user_selection
from app.labels_system import bp
......@@ -23,19 +23,3 @@ def search(number_of_mandatory_labels: int, optional1: str, optional2: str) -> L
result = [selected_elements, high_discriminating_labels]
return json.dumps(result)
def get_user_selection(number_of_mandatory_labels: int, optional1: str, optional2: str) -> tuple :
'''
Return the right values of id_mandatory_labels and id_forbiden_labels when optional2 is missing.
It is necessary because optional1 could be id_mandatory_labels or id_forbiden_labels.
:param number_of_mandatory_labels: int
:param optional1: str
:param optional2: str
:return:
'''
if int(number_of_mandatory_labels):
id_mandatory_labels = optional1
id_forbiden_labels = optional2
else:
id_mandatory_labels = optional2
id_forbiden_labels = optional1
return id_mandatory_labels, id_forbiden_labels
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment