update clean/seed tasks
parent
2bba7eaf98
commit
6589faa2e3
|
@ -8,7 +8,7 @@ def create_schema(connection) -> None:
|
||||||
CREATE TYPE suggestion AS (id uuid, rank int);
|
CREATE TYPE suggestion AS (id uuid, rank int);
|
||||||
CREATE SCHEMA oapen_suggestions
|
CREATE SCHEMA oapen_suggestions
|
||||||
CREATE TABLE IF NOT EXISTS suggestions (
|
CREATE TABLE IF NOT EXISTS suggestions (
|
||||||
item_id uuid PRIMARY KEY,
|
handle text PRIMARY KEY,
|
||||||
name text,
|
name text,
|
||||||
suggestions suggestion[]
|
suggestions suggestion[]
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import data.oapen as OapenAPI
|
import data.oapen as OapenAPI
|
||||||
from data.connection import get_connection
|
from data.connection import get_connection
|
||||||
from data.oapen_db import add_many_suggestions
|
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):
|
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 = []
|
rows = []
|
||||||
for i in range(min(10, len(items))):
|
for i in range(min(10, len(items))):
|
||||||
item = transform_item_data(OapenAPI.get_item(items[i]))
|
rows.append((items[i].handle, items[i].name, [(items[i], i)]))
|
||||||
rows.append((items[i], item.name, [(items[i], i)]))
|
|
||||||
|
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue