gamingflexer commited on
Commit
ce5b6dd
·
1 Parent(s): 5718d42

Add function to get unique authors

Browse files
Files changed (1) hide show
  1. src/db/db_functions.py +9 -2
src/db/db_functions.py CHANGED
@@ -6,6 +6,7 @@ from fuzzywuzzy import fuzz
6
  from config import SUPABASE_URL, SUPABASE_KEY
7
  import json
8
  import logging
 
9
 
10
  url: str = SUPABASE_URL
11
  key: str = SUPABASE_KEY
@@ -53,7 +54,13 @@ def get_correct_author_name(user_input_author):
53
  def fetch_papers_data(author_name, fields_to_query = ["doi_no"],table_name: str = 'papers', all=False):
54
  author_name = get_correct_author_name(author_name)
55
  if all:
56
- data, count = supabase.table(table_name).select("*").eq('author_name', author_name).execute()
57
  return data
58
  data, count = supabase.table(table_name).select(",".join(fields_to_query)).eq('author_name', author_name).execute()
59
- return data[1]
 
 
 
 
 
 
 
6
  from config import SUPABASE_URL, SUPABASE_KEY
7
  import json
8
  import logging
9
+ import pandas as pd
10
 
11
  url: str = SUPABASE_URL
12
  key: str = SUPABASE_KEY
 
54
  def fetch_papers_data(author_name, fields_to_query = ["doi_no"],table_name: str = 'papers', all=False):
55
  author_name = get_correct_author_name(author_name)
56
  if all:
57
+ data, count = supabase.table(table_name).select("*").execute()
58
  return data
59
  data, count = supabase.table(table_name).select(",".join(fields_to_query)).eq('author_name', author_name).execute()
60
+ return data[1]
61
+
62
+ def get_unquine_authors():
63
+ authors_name_data = supabase.table('papers').select('author_name').execute()
64
+ unique_authors = set(author_dict['author_name'] for author_dict in authors_name_data.data)
65
+ unique_authors_df = pd.DataFrame(unique_authors, columns=['author_name'])
66
+ return unique_authors_df