Spaces:
Running
Running
Update to prod test
Browse files
app.py
CHANGED
|
@@ -15,17 +15,19 @@ blob_service_client = BlobServiceClient.from_connection_string(connection_string
|
|
| 15 |
def upload_blob(pdf_name, json_data, pdf_data_jobdescription,pdf_data_cvs):
|
| 16 |
try:
|
| 17 |
container_name = "jobdescriptions"
|
| 18 |
-
json_blob_name = f"{pdf_name}_jsondata.json"
|
| 19 |
pdf_blob_name_jobdescription = f"{pdf_name}.pdf"
|
| 20 |
|
| 21 |
container_client = blob_service_client.get_container_client(container_name)
|
| 22 |
|
| 23 |
-
json_blob_client = container_client.get_blob_client(json_blob_name)
|
| 24 |
-
json_blob_client.upload_blob(json_data.encode('utf-8'), overwrite=True)
|
| 25 |
|
| 26 |
pdf_blob_client = container_client.get_blob_client(pdf_blob_name_jobdescription)
|
| 27 |
pdf_blob_client.upload_blob(pdf_data_jobdescription, overwrite=True)
|
| 28 |
|
|
|
|
|
|
|
| 29 |
links = []
|
| 30 |
names = []
|
| 31 |
for i,cv in enumerate(pdf_data_cvs):
|
|
@@ -51,6 +53,32 @@ def upload_blob(pdf_name, json_data, pdf_data_jobdescription,pdf_data_cvs):
|
|
| 51 |
print(f"Fehler beim Hochladen der Daten: {str(e)}")
|
| 52 |
return False
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
def upload_db_item(name, data, job_description_id, cv_id):
|
| 55 |
|
| 56 |
endpoint = "https://wg-candidate-data.documents.azure.com:443/"
|
|
@@ -75,7 +103,7 @@ def upload_db_item(name, data, job_description_id, cv_id):
|
|
| 75 |
try:
|
| 76 |
# Fügen Sie das Element in den Container ein
|
| 77 |
container.create_item(body=candidate_item)
|
| 78 |
-
print("Eintrag erfolgreich in die Cosmos DB eingefügt.")
|
| 79 |
except exceptions.CosmosHttpResponseError as e:
|
| 80 |
print(f"Fehler beim Schreiben in die Cosmos DB: {str(e)}")
|
| 81 |
except Exception as e:
|
|
|
|
| 15 |
def upload_blob(pdf_name, json_data, pdf_data_jobdescription,pdf_data_cvs):
|
| 16 |
try:
|
| 17 |
container_name = "jobdescriptions"
|
| 18 |
+
# json_blob_name = f"{pdf_name}_jsondata.json"
|
| 19 |
pdf_blob_name_jobdescription = f"{pdf_name}.pdf"
|
| 20 |
|
| 21 |
container_client = blob_service_client.get_container_client(container_name)
|
| 22 |
|
| 23 |
+
# json_blob_client = container_client.get_blob_client(json_blob_name)
|
| 24 |
+
# json_blob_client.upload_blob(json_data.encode('utf-8'), overwrite=True)
|
| 25 |
|
| 26 |
pdf_blob_client = container_client.get_blob_client(pdf_blob_name_jobdescription)
|
| 27 |
pdf_blob_client.upload_blob(pdf_data_jobdescription, overwrite=True)
|
| 28 |
|
| 29 |
+
upload_job_db_item(pdf_name,len(pdf_data_cvs),json.loads(json_data))
|
| 30 |
+
|
| 31 |
links = []
|
| 32 |
names = []
|
| 33 |
for i,cv in enumerate(pdf_data_cvs):
|
|
|
|
| 53 |
print(f"Fehler beim Hochladen der Daten: {str(e)}")
|
| 54 |
return False
|
| 55 |
|
| 56 |
+
def upload_job_db_item(id, number_of_applicants, data):
|
| 57 |
+
endpoint = "https://wg-candidate-data.documents.azure.com:443/"
|
| 58 |
+
key = os.getenv("CONNECTION_DB")
|
| 59 |
+
client = CosmosClient(endpoint, key)
|
| 60 |
+
database = client.get_database_client("ToDoList")
|
| 61 |
+
container = database.get_container_client("JobData")
|
| 62 |
+
job_item = {
|
| 63 |
+
"id": id,
|
| 64 |
+
'partitionKey' : 'wg-job-data-v1',
|
| 65 |
+
"title": data["title"],
|
| 66 |
+
"number_of_applicants": number_of_applicants,
|
| 67 |
+
"every_interview_conducted": False,
|
| 68 |
+
"evaluation_email": data["email"],
|
| 69 |
+
"question_one": data["question_one"],
|
| 70 |
+
"question_two": data["question_two"],
|
| 71 |
+
"question_three": data["question_three"],
|
| 72 |
+
}
|
| 73 |
+
try:
|
| 74 |
+
# Fügen Sie das Element in den Container ein
|
| 75 |
+
container.create_item(body=job_item)
|
| 76 |
+
print("Eintrag erfolgreich in die Cosmos DB eingefügt. Container: Job Data")
|
| 77 |
+
except exceptions.CosmosHttpResponseError as e:
|
| 78 |
+
print(f"Fehler beim Schreiben in die Cosmos DB: {str(e)}")
|
| 79 |
+
except Exception as e:
|
| 80 |
+
print(f"Allgemeiner Fehler: {str(e)}")
|
| 81 |
+
|
| 82 |
def upload_db_item(name, data, job_description_id, cv_id):
|
| 83 |
|
| 84 |
endpoint = "https://wg-candidate-data.documents.azure.com:443/"
|
|
|
|
| 103 |
try:
|
| 104 |
# Fügen Sie das Element in den Container ein
|
| 105 |
container.create_item(body=candidate_item)
|
| 106 |
+
print("Eintrag erfolgreich in die Cosmos DB eingefügt. Container: Items(candidate Data)")
|
| 107 |
except exceptions.CosmosHttpResponseError as e:
|
| 108 |
print(f"Fehler beim Schreiben in die Cosmos DB: {str(e)}")
|
| 109 |
except Exception as e:
|