39 lines
659 B
Python
39 lines
659 B
Python
from database import execute, fetch_one
|
|
|
|
|
|
def respond_to_event(event_id, user_id, status):
|
|
|
|
query = """
|
|
INSERT INTO event_signups
|
|
(event_id, user_id, status)
|
|
VALUES (?, ?, ?)
|
|
|
|
ON CONFLICT(event_id, user_id)
|
|
DO UPDATE SET status = excluded.status
|
|
"""
|
|
|
|
return execute(
|
|
query,
|
|
(
|
|
event_id,
|
|
user_id,
|
|
status
|
|
)
|
|
)
|
|
|
|
|
|
def count_confirmations(event_id):
|
|
|
|
query = """
|
|
SELECT COUNT(*) as amount
|
|
FROM event_signups
|
|
WHERE event_id = ?
|
|
AND status = 'going'
|
|
"""
|
|
|
|
result = fetch_one(
|
|
query,
|
|
(event_id,)
|
|
)
|
|
|
|
return result["amount"] |