acecalisto3 commited on
Commit
2ff1685
·
verified ·
1 Parent(s): dacbb03

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +6 -7
app2.py CHANGED
@@ -219,7 +219,7 @@ async def update_db_status(db_status):
219
  return db_status
220
 
221
 
222
- async def update_feed_content(db_session):
223
  try:
224
  articles = await db_session.query(Article).order_by(
225
  Article.timestamp.desc()).limit(20).all()
@@ -231,7 +231,7 @@ async def update_feed_content(db_session):
231
  'title': article.title,
232
  'link': article.url,
233
  'description': article.content,
234
- 'pubDate': article.timestamp
235
  } for article in articles]
236
  }
237
  return feed
@@ -239,7 +239,6 @@ async def update_feed_content(db_session):
239
  logger.error(f"Database error: {e}")
240
  return None
241
 
242
-
243
  async def periodic_update_with_error_handling(db_session):
244
  while True:
245
  try:
@@ -321,14 +320,14 @@ async def main():
321
  inputs=[message_input, chatbot_interface],
322
  outputs=[chatbot_interface, message_input])
323
 
324
- feed_updater = gr.Timer(300)
325
- feed_updater.tick(fn=update_feed_content,
326
- inputs=[db_session],
327
- outputs=feed_content)
328
 
329
  asyncio.create_task(periodic_update_with_error_handling(db_session))
330
  asyncio.create_task(update_db_status(db_status))
331
 
 
 
 
332
  try:
333
  await demo.launch()
334
  finally:
 
219
  return db_status
220
 
221
 
222
+ async def update_feed_content(): # Remove db_session parameter
223
  try:
224
  articles = await db_session.query(Article).order_by(
225
  Article.timestamp.desc()).limit(20).all()
 
231
  'title': article.title,
232
  'link': article.url,
233
  'description': article.content,
234
+ 'pubDate': str(article.timestamp) # Convert datetime to string
235
  } for article in articles]
236
  }
237
  return feed
 
239
  logger.error(f"Database error: {e}")
240
  return None
241
 
 
242
  async def periodic_update_with_error_handling(db_session):
243
  while True:
244
  try:
 
320
  inputs=[message_input, chatbot_interface],
321
  outputs=[chatbot_interface, message_input])
322
 
323
+
 
 
 
324
 
325
  asyncio.create_task(periodic_update_with_error_handling(db_session))
326
  asyncio.create_task(update_db_status(db_status))
327
 
328
+ feed_updater = gr.Timer(300) # 5 minutes
329
+ feed_updater.tick(fn=update_feed_content,
330
+ outputs=feed_content)
331
  try:
332
  await demo.launch()
333
  finally: