File size: 854 Bytes
c8fa3bd
 
ae9d4c8
c8fa3bd
 
 
 
 
 
 
6505613
c8fa3bd
 
 
 
 
 
 
 
6505613
 
 
c8fa3bd
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# insert_problems.py
import logging
from backend.app.database.supabase_client import supabase


logging.basicConfig(level=logging.INFO)


def insert_questions(problems):
    for prob in problems:
        prob['topicTags'] = '@'.join(prob.get('topicTags', []))
        supabase.table("problems_bge").upsert({
            "id": prob["id"],
            "title": prob["title"],
            "url": prob["url"],
            "paid_only": prob["paidOnly"],
            "content": prob.get("content", ""),
            "original_content": prob.get("original_content", ""),
            "embedding": prob.get("embedding", []),
            "id_num": int(prob["id"]),
            "difficulty": prob["difficulty"],
            "topictags": prob["topicTags"]
        }, on_conflict=["id"]).execute()
    logging.info(f"Inserted {len(problems)} problems into Supabase.")