pgzmnk commited on
Commit
4b7975c
1 Parent(s): 77d952e

Filter projects based on project authorId.

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -320,8 +320,10 @@ def push_to_md():
320
  logging.info("upsert records into motherduck")
321
 
322
 
323
- def motherduck_list_projects():
324
- return con.sql("SELECT DISTINCT name FROM project").df()
 
 
325
 
326
 
327
  with gr.Blocks() as demo:
@@ -371,8 +373,11 @@ with gr.Blocks() as demo:
371
  view_btn.click(view_all, outputs=results_df)
372
  save_btn.click(push_to_md)
373
 
374
- def update_project_dropdown_list(x):
375
- projects = motherduck_list_projects()
 
 
 
376
  # to-do: filter projects based on user
377
  return gr.Dropdown.update(choices=projects["name"].tolist())
378
 
 
320
  logging.info("upsert records into motherduck")
321
 
322
 
323
+ def motherduck_list_projects(author_id):
324
+ return con.sql(f"""
325
+ SELECT DISTINCT name FROM project WHERE authorId = '{author_id}'
326
+ """).df()
327
 
328
 
329
  with gr.Blocks() as demo:
 
373
  view_btn.click(view_all, outputs=results_df)
374
  save_btn.click(push_to_md)
375
 
376
+ def update_project_dropdown_list(url_params):
377
+ print('url_params', url_params['username'])
378
+
379
+ projects = motherduck_list_projects(author_id = url_params['username'])
380
+ print('projects', projects)
381
  # to-do: filter projects based on user
382
  return gr.Dropdown.update(choices=projects["name"].tolist())
383