Skip to content

Commit

Permalink
Add short description to incidents
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoCeratto committed Aug 24, 2023
1 parent 2b7b1ba commit afaa615
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
7 changes: 7 additions & 0 deletions api/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
ooni-api (1.0.6) UNRELEASED; urgency=medium

* Add short description to incidents
https://github.com/ooni/backend/issues/708

-- Federico Ceratto <[email protected]> Thu, 24 Aug 2023 17:31:40 +0200

ooni-api (1.0.64) unstable; urgency=medium

* Set "mine" and "archived" as bools
Expand Down
13 changes: 7 additions & 6 deletions api/ooniapi/incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def search_list_incidents() -> Response:

query = f"""SELECT id, update_time, start_time, end_time, reported_by,
title, event_type, published, CCs, ASNs, domains, tags, test_names,
links, creator_account_id = %(account_id)s AS mine
links, short_description, creator_account_id = %(account_id)s AS mine
FROM incidents FINAL
{where}
ORDER BY title
Expand Down Expand Up @@ -127,7 +127,7 @@ def show_incident(incident_id: str) -> Response:

query = f"""SELECT id, update_time, start_time, end_time, reported_by,
title, text, event_type, published, CCs, ASNs, domains, tags, test_names,
links, creator_account_id = %(account_id)s AS mine
links, short_description, creator_account_id = %(account_id)s AS mine
FROM incidents FINAL
{where}
LIMIT 1
Expand Down Expand Up @@ -156,11 +156,12 @@ def prepare_incident_dict(d: dict):
"links",
"published",
"reported_by",
"short_description",
"start_time",
"tags",
"test_names",
"text",
"title",
"title"
]
if sorted(d) != exp:
log.debug(f"Invalid incident update request. Keys: {sorted(d)}")
Expand Down Expand Up @@ -209,12 +210,12 @@ def post_update_incident(action: str) -> Response:
type: string
title:
type: string
short_description:
type: string
start_time:
type: string
reported_by:
type: string
title:
type: string
text:
type: string
published:
Expand Down Expand Up @@ -298,7 +299,7 @@ def post_update_incident(action: str) -> Response:
ins_sql = """INSERT INTO incidents
(id, start_time, end_time, creator_account_id, reported_by, title,
text, event_type, published, CCs, ASNs, domains, tags, links,
test_names)
test_names, short_description)
VALUES
"""
prepare_incident_dict(req)
Expand Down
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 @@ -232,7 +232,8 @@ CREATE TABLE IF NOT EXISTS default.incidents
`domains` Array(String),
`tags` Array(String),
`links` Array(String),
`test_names` Array(String)
`test_names` Array(String),
`short_description` String,
)
ENGINE = ReplacingMergeTree(update_time)
ORDER BY (id)
Expand Down
6 changes: 6 additions & 0 deletions api/tests/integ/test_incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def test_crud_general(cleanup, client, adminsession, usersession):
end_time=None,
reported_by="ooni",
title="integ-test-1",
short_description="integ test",
text="foo bar\nbaz\n",
event_type="incident",
published=False,
Expand Down Expand Up @@ -80,6 +81,7 @@ def test_crud_general(cleanup, client, adminsession, usersession):
"start_time": "2020-01-01T00:00:00Z",
"tags": ["integ-test"],
"title": "integ-test-1",
"short_description": "integ test",
"test_names": ["web_connectivity", "signal"],
"event_type": "incident",
"mine": 1,
Expand Down Expand Up @@ -161,6 +163,7 @@ def test_crud_user_create(cleanup, client, adminsession, usersession):
end_time=None,
reported_by="ooni",
title=title,
short_description="integ test",
text="foo bar\nbaz\n",
event_type="incident",
published=True,
Expand Down Expand Up @@ -199,6 +202,7 @@ def test_crud_user_create(cleanup, client, adminsession, usersession):
"start_time": "2020-01-01T00:00:00Z",
"tags": ["integ-test"],
"title": title,
"short_description": "integ test",
"test_names": ["web_connectivity"],
"mine": 1,
"event_type": "incident",
Expand All @@ -213,6 +217,7 @@ def test_crud_invalid_fields(client, adminsession, usersession):
end_time=None,
reported_by="ooni",
title="", # empty
short_description="integ test",
text="foo bar\nbaz\n",
event_type="incident",
published=False,
Expand All @@ -237,6 +242,7 @@ def test_crud_extra_field(client, adminsession, usersession):
end_time=None,
reported_by="ooni",
title="",
short_description="integ test",
text="foo bar\nbaz\n",
event_type="incident",
published=False,
Expand Down

0 comments on commit afaa615

Please sign in to comment.