Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -19,8 +19,8 @@ for webhook in client.webhooks:
|
|
19 |
print(f"Deleting webhook: {webhook.url}")
|
20 |
webhook.delete()
|
21 |
|
22 |
-
@webhook_listener(events="
|
23 |
-
async def update_validation_space_on_answer(
|
24 |
"""
|
25 |
Webhook listener that triggers when a new response is added to an answering space.
|
26 |
It will automatically update the corresponding validation space with the new response.
|
@@ -28,9 +28,6 @@ async def update_validation_space_on_answer(event):
|
|
28 |
Args:
|
29 |
event: The webhook event containing the user response data
|
30 |
"""
|
31 |
-
response = event.response
|
32 |
-
|
33 |
-
record = response.record
|
34 |
|
35 |
dataset_name = record.dataset.name
|
36 |
if not dataset_name.endswith("_responder_preguntas"):
|
@@ -53,31 +50,32 @@ async def update_validation_space_on_answer(event):
|
|
53 |
|
54 |
validation_dataset.records.log(records=[validation_record])
|
55 |
|
|
|
56 |
print(f"Added new response to validation space for {country}")
|
57 |
|
58 |
|
59 |
# Create a webhook for record events
|
60 |
-
@rg.webhook_listener(events=["record.deleted", "record.completed"])
|
61 |
-
async def record_events(record: rg.Record, type: str, timestamp: datetime):
|
62 |
-
|
63 |
|
64 |
-
|
65 |
|
66 |
|
67 |
# Create a webhook for dataset events
|
68 |
-
@rg.webhook_listener(events=["dataset.created", "dataset.updated", "dataset.deleted", "dataset.published"])
|
69 |
-
async def dataset_events(dataset: rg.Dataset, type: str, timestamp: datetime):
|
70 |
-
|
71 |
|
72 |
-
|
73 |
|
74 |
|
75 |
# Create a webhook for response events
|
76 |
-
@rg.webhook_listener(events=["response.created", "response.updated"])
|
77 |
-
async def response_events(response: rg.UserResponse, type: str, timestamp: datetime):
|
78 |
-
|
79 |
|
80 |
-
|
81 |
|
82 |
|
83 |
def read_next_event():
|
|
|
19 |
print(f"Deleting webhook: {webhook.url}")
|
20 |
webhook.delete()
|
21 |
|
22 |
+
@webhook_listener(events="record.completed")
|
23 |
+
async def update_validation_space_on_answer(record: rg.Record, type: str):
|
24 |
"""
|
25 |
Webhook listener that triggers when a new response is added to an answering space.
|
26 |
It will automatically update the corresponding validation space with the new response.
|
|
|
28 |
Args:
|
29 |
event: The webhook event containing the user response data
|
30 |
"""
|
|
|
|
|
|
|
31 |
|
32 |
dataset_name = record.dataset.name
|
33 |
if not dataset_name.endswith("_responder_preguntas"):
|
|
|
50 |
|
51 |
validation_dataset.records.log(records=[validation_record])
|
52 |
|
53 |
+
incoming_events.put({"event": type, "data": record})
|
54 |
print(f"Added new response to validation space for {country}")
|
55 |
|
56 |
|
57 |
# Create a webhook for record events
|
58 |
+
# @rg.webhook_listener(events=["record.deleted", "record.completed"])
|
59 |
+
# async def record_events(record: rg.Record, type: str, timestamp: datetime):
|
60 |
+
# print(f"Received event type {type} at {timestamp}: ", record)
|
61 |
|
62 |
+
# incoming_events.put({"event": type, "data": record})
|
63 |
|
64 |
|
65 |
# Create a webhook for dataset events
|
66 |
+
# @rg.webhook_listener(events=["dataset.created", "dataset.updated", "dataset.deleted", "dataset.published"])
|
67 |
+
# async def dataset_events(dataset: rg.Dataset, type: str, timestamp: datetime):
|
68 |
+
# print(f"Received event type {type} at {timestamp}: ", dataset)
|
69 |
|
70 |
+
# incoming_events.put({"event": type, "data": dataset})
|
71 |
|
72 |
|
73 |
# Create a webhook for response events
|
74 |
+
# @rg.webhook_listener(events=["response.created", "response.updated"])
|
75 |
+
# async def response_events(response: rg.UserResponse, type: str, timestamp: datetime):
|
76 |
+
# print(f"Received event type {type} at {timestamp}: ", response)
|
77 |
|
78 |
+
# incoming_events.put({"event": type, "data": response})
|
79 |
|
80 |
|
81 |
def read_next_event():
|