| 226 | |
| 227 | @failsoft |
| 228 | def create_session(app_name, user_id): |
| 229 | if not EVENTS_ENGINE: |
| 230 | return None |
| 231 | |
| 232 | parms = { |
| 233 | "app_name": app_name, |
| 234 | "user_id": user_id, |
| 235 | } |
| 236 | create_query = text(""" |
| 237 | INSERT INTO sessions (app_name, user_id) |
| 238 | VALUES (:app_name, :user_id) |
| 239 | returning id |
| 240 | """) |
| 241 | with EVENTS_ENGINE.connect() as conn: |
| 242 | # get the ID back |
| 243 | result = conn.execute(create_query, parms) |
| 244 | conn.commit() |
| 245 | row = result.fetchone() |
| 246 | session_id = row[0] |
| 247 | |
| 248 | return str(session_id) |
| 249 | |
| 250 | @failsoft |
| 251 | def get_feed_data(app): |