Skip to content

Commit

Permalink
Extract and list icon
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoCeratto authored and Federico Ceratto committed Aug 9, 2023
1 parent c59705c commit ae20974
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions api/ooniapi/oonirun.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,14 @@ def create_oonirun() -> Response:
name=descriptor["name"],
short_description=descriptor.get("short_description", ""),
translation_creation_time=now,
icon=descriptor.get("icon", ""),
)
log.info(
f"Inserting oonirun {oonirun_id} {increase_descriptor_creation_time} {row}"
)
sql_ins = """INSERT INTO oonirun (id, descriptor, creator_account_id,
author, descriptor_creation_time, translation_creation_time, name,
short_description) VALUES"""
short_description, icon) VALUES"""
insert_click(sql_ins, [row])

optimize_table("oonirun")
Expand Down Expand Up @@ -308,6 +309,8 @@ def list_oonirun_descriptors() -> Response:
type: string
short_description:
type: string
icon:
type: string
"""
global log
log = current_app.logger
Expand Down Expand Up @@ -356,12 +359,11 @@ def list_oonirun_descriptors() -> Response:
else:
fil = ""

query = f"""SELECT archived, author, id, descriptor_creation_time,
query = f"""SELECT archived, author, id, icon, descriptor_creation_time,
translation_creation_time, {mine_col} AS mine, name, short_description
FROM oonirun
{fil}
"""
descriptors = list(query_click(query, query_params))
log.debug(f"Returning {len(descriptors)} descriptor[s]")

return nocachejson(v=1, descriptors=descriptors)
3 changes: 2 additions & 1 deletion api/tests/integ/clickhouse_1_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ CREATE TABLE IF NOT EXISTS default.oonirun
`descriptor` String,
`author` String,
`name` String,
`short_description` String
`short_description` String,
`icon` String
)
ENGINE = ReplacingMergeTree(translation_creation_time)
ORDER BY (id, descriptor_creation_time)
Expand Down
6 changes: 4 additions & 2 deletions api/tests/integ/test_oonirun.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_create_fetch_archive(cleanup, client, usersession, adminsession):
"short_description_intl": {
"it": "integ-test descrizione breve in italiano",
},
"icon": "",
"icon": "myicon",
"author": "integ-test author",
"nettests": [
{
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_create_fetch_archive(cleanup, client, usersession, adminsession):
"short_description_intl": {
"it": "integ-test descrizione breve in italiano",
},
"icon": "",
"icon": "myicon",
"author": "integ-test author",
"nettests": [
{
Expand Down Expand Up @@ -129,6 +129,7 @@ def test_create_fetch_archive(cleanup, client, usersession, adminsession):
"archived",
"author",
"descriptor_creation_time",
"icon",
"id",
"mine",
"name",
Expand Down Expand Up @@ -171,6 +172,7 @@ def test_create_fetch_archive(cleanup, client, usersession, adminsession):
"archived": 0,
"author": "integ-test author",
"descriptor_creation_time": creation_time,
"icon": "myicon",
"id": oonirun_id,
"mine": 0,
"name": "integ-test name in English",
Expand Down

0 comments on commit ae20974

Please sign in to comment.