(20250614) Ready for deployment with the UI.
This commit is contained in:
@@ -47,6 +47,7 @@ from quart import Blueprint, current_app, make_response
|
||||
|
||||
# My utils:
|
||||
from utils_v2.string import json
|
||||
from utils_v2.date_time import date_time
|
||||
from utils_v2.api.codes import StatusCodes, HttpCodes
|
||||
from utils_v2.api.response import ResponseModel
|
||||
from utils_v2.api.async_quart import (
|
||||
@@ -157,6 +158,9 @@ async def set_data(
|
||||
:return: A standard response structure.
|
||||
"""
|
||||
|
||||
# Get the current date-time:
|
||||
now = date_time.get_current_utc_date_time()
|
||||
|
||||
# If an invalid choice was made:
|
||||
if json_type not in JSON_TYPE_INFO.keys():
|
||||
return ResponseModel(
|
||||
@@ -171,14 +175,18 @@ async def set_data(
|
||||
document = {
|
||||
"scriptId": inbound_headers["X-Script-Id"],
|
||||
"desc": description,
|
||||
"content": inbound_data
|
||||
"content": inbound_data,
|
||||
"lastUpdateTs": now
|
||||
}
|
||||
|
||||
# Make an attempt to set the credentials:
|
||||
success = await current_app.mongo.replace_one(
|
||||
success = await current_app.mongo.update_one(
|
||||
collection = JSON_TYPE_INFO[json_type]["collection"],
|
||||
filter = {"scriptId": inbound_headers["X-Script-Id"]},
|
||||
replacement = document,
|
||||
update = {
|
||||
"$set": document,
|
||||
"$setOnInsert": {"firstSetTs": now},
|
||||
},
|
||||
upsert = True,
|
||||
raise_exception = True
|
||||
)
|
||||
@@ -227,6 +235,9 @@ async def get_data(
|
||||
:return: A standard response structure.
|
||||
"""
|
||||
|
||||
# Get the current date-time:
|
||||
now = date_time.get_current_utc_date_time()
|
||||
|
||||
# If an invalid choice was made:
|
||||
if json_type not in JSON_TYPE_INFO.keys():
|
||||
return ResponseModel(
|
||||
@@ -236,9 +247,11 @@ async def get_data(
|
||||
)
|
||||
|
||||
# Make an attempt to retrieve the credentials:
|
||||
data_json = await current_app.mongo.find_one(
|
||||
data_json = await current_app.mongo.find_one_and_update(
|
||||
collection = JSON_TYPE_INFO[json_type]["collection"],
|
||||
filter = {"scriptId": inbound_headers["X-Script-Id"]},
|
||||
update = {"$set": {"lastFetchTs": now}},
|
||||
return_updated = True,
|
||||
projection = {"_id": False, "scriptId": False},
|
||||
raise_exception = True
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user