update clean/seed tasks

pull/17/head
Celina Peralta 2022-10-18 13:39:16 -04:00
parent 2bba7eaf98
commit 6589faa2e3
2 changed files with 8 additions and 5 deletions

View File

@ -8,7 +8,7 @@ def create_schema(connection) -> None:
CREATE TYPE suggestion AS (id uuid, rank int);
CREATE SCHEMA oapen_suggestions
CREATE TABLE IF NOT EXISTS suggestions (
item_id uuid PRIMARY KEY,
handle text PRIMARY KEY,
name text,
suggestions suggestion[]
);

View File

@ -1,16 +1,19 @@
from typing import List
import data.oapen as OapenAPI
from data.connection import get_connection
from data.oapen_db import add_many_suggestions
from model.oapen_types import transform_item_data
from model.oapen_types import OapenItem
def mock_suggestion_rows(n=10):
items = OapenAPI.get_items_from_collection("5f664493-8fee-465a-9c22-7ea8e0595775")
items: List[OapenItem] = OapenAPI.get_collection_items_by_label(
"Knowledge Unlatched (KU)"
)
rows = []
for i in range(min(10, len(items))):
item = transform_item_data(OapenAPI.get_item(items[i]))
rows.append((items[i], item.name, [(items[i], i)]))
rows.append((items[i].handle, items[i].name, [(items[i], i)]))
return rows