Skip to content

Commit

Permalink
chore: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
rti committed Apr 30, 2024
1 parent b82e093 commit e6ad9f5
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,48 +99,3 @@ def get_similar_chunks_with_distance(
)
for r in res
]


def get_random_chunks(limit=5) -> List[Chunk]:
cur = get_connection().cursor()
cur.execute(
"""
SELECT c.id, c.page_id, p.title, p.description, c.text
FROM chunks c
JOIN pages p ON c.page_id = p.id
ORDER BY RANDOM()
LIMIT %s;
""",
(limit,),
)
res = cur.fetchall()
cur.close()

return [
Chunk(id=r[0], pageId=r[1], title=r[2], description=r[3], text=r[4])
for r in res
]


def get_pages(limit=10) -> List[Page]:
cur = get_connection().cursor()
cur.execute(
"SELECT id, title, description, text FROM pages LIMIT %s;",
(limit,),
)
res = cur.fetchall()
cur.close()

return [Page(id=r[0], title=r[1], description=r[2], text=r[3]) for r in res]


def get_random_pages(limit=10) -> List[Page]:
cur = get_connection().cursor()
cur.execute(
"SELECT id, title, description, text FROM pages ORDER BY RANDOM() LIMIT %s;",
(limit,),
)
res = cur.fetchall()
cur.close()

return [Page(id=r[0], title=r[1], description=r[2], text=r[3]) for r in res]

0 comments on commit e6ad9f5

Please sign in to comment.