Open onlyjazz opened 1 hour ago
Bug was in insert_post - not initializing the prompt_identifier
Solved with:
def get_prompt_identifier():
# Get the latest round of the publishing cycle
query = f'*[_type == "cycle"]{{round}}'
data = query_sanity_documents(query)
current_cycle = data['result'][0]['round']
# Get the prompt.identifier for this cycle
query = f'*[_type == "prompt" && cycle=={current_cycle}].identifier'
data = query_sanity_documents(query)
prompt_identifier = data['result'][0]
return prompt_identifier
def insert_post(post_header, post_content):
"""
Inserts a new post document into the Sanity Content Lake.
Args:
- document: The document to insert (should be a dictionary).
Returns:
- Response from the Sanity API.
"""
cta = get_cta()
post_content_cta = post_content + "\n\n" + cta
url = f"https://{project_id}.api.sanity.io/{api_version}/data/mutate/{dataset}"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {token}"
}
doc = {
"_type": "post",
"header": post_header,
"prompt_identifier": get_prompt_identifier(),
Running in the Pycharm debugger console
Is there a 15' timeout?
No 429 messages