Update modules/database.py
Browse files- modules/database.py +13 -6
modules/database.py
CHANGED
@@ -43,6 +43,7 @@ def initialize_cosmos_sql_connection():
|
|
43 |
cosmos_client = CosmosClient(cosmos_endpoint, cosmos_key)
|
44 |
user_database = cosmos_client.get_database_client("user_database")
|
45 |
user_container = user_database.get_container_client("users")
|
|
|
46 |
|
47 |
print(f"user_container initialized: {user_container is not None}")
|
48 |
logger.info("Conexi贸n a Cosmos DB SQL API exitosa")
|
@@ -135,17 +136,23 @@ def get_user(username):
|
|
135 |
#######################################################################################################
|
136 |
def store_application_request(name, email, institution, role, reason):
|
137 |
try:
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
logger.info(f"Application request stored for email: {email}")
|
144 |
return True
|
145 |
except Exception as e:
|
146 |
logger.error(f"Error storing application request: {str(e)}")
|
147 |
return False
|
148 |
-
|
149 |
#######################################################################################################
|
150 |
def store_morphosyntax_result(username, text, repeated_words, arc_diagrams):
|
151 |
if analysis_collection is None:
|
|
|
43 |
cosmos_client = CosmosClient(cosmos_endpoint, cosmos_key)
|
44 |
user_database = cosmos_client.get_database_client("user_database")
|
45 |
user_container = user_database.get_container_client("users")
|
46 |
+
application_requests_container = user_database.get_container_client("application_requests")
|
47 |
|
48 |
print(f"user_container initialized: {user_container is not None}")
|
49 |
logger.info("Conexi贸n a Cosmos DB SQL API exitosa")
|
|
|
136 |
#######################################################################################################
|
137 |
def store_application_request(name, email, institution, role, reason):
|
138 |
try:
|
139 |
+
application_request = {
|
140 |
+
"id": str(uuid.uuid4()), # Generar un ID 煤nico
|
141 |
+
"name": name,
|
142 |
+
"email": email,
|
143 |
+
"institution": institution,
|
144 |
+
"role": role,
|
145 |
+
"reason": reason,
|
146 |
+
"requestDate": datetime.utcnow().isoformat()
|
147 |
+
}
|
148 |
+
|
149 |
+
application_requests_container.create_item(body=application_request)
|
150 |
logger.info(f"Application request stored for email: {email}")
|
151 |
return True
|
152 |
except Exception as e:
|
153 |
logger.error(f"Error storing application request: {str(e)}")
|
154 |
return False
|
155 |
+
|
156 |
#######################################################################################################
|
157 |
def store_morphosyntax_result(username, text, repeated_words, arc_diagrams):
|
158 |
if analysis_collection is None:
|