Skip to content

Commit

Permalink
refactor: changes to model from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
DecFox committed Jul 25, 2024
1 parent e0d52bb commit af0efde
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def upgrade() -> None:
sa.Column("event_type", sa.String(), nullable=False),
sa.Column("published", sa.Integer(), nullable=False),
sa.Column("deleted", sa.Integer(), nullable=False, default=0),
sa.Column("CCs", sa.JSON(), nullable=True),
sa.Column("ASNs", sa.JSON(), nullable=True),
sa.Column("country_codes", sa.JSON(), nullable=True),
sa.Column("asns", sa.JSON(), nullable=True),
sa.Column("domains", sa.JSON(), nullable=True),
sa.Column("tags", sa.JSON(), nullable=True),
sa.Column("links", sa.JSON(), nullable=True),
Expand Down
4 changes: 2 additions & 2 deletions ooniapi/services/oonifindings/src/oonifindings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class OONIFinding(Base):
published: Mapped[int] = mapped_column()
deleted: Mapped[int] = mapped_column(default=0)

CCs: Mapped[List[str]] = mapped_column(nullable=True)
ASNs: Mapped[List[str]] = mapped_column(nullable=True)
country_codes: Mapped[List[str]] = mapped_column(nullable=True)
asns: Mapped[List[str]] = mapped_column(nullable=True)
domains: Mapped[List[str]] = mapped_column(nullable=True)
tags: Mapped[List[str]] = mapped_column(nullable=True)
links: Mapped[List[str]] = mapped_column(nullable=True)
Expand Down
16 changes: 8 additions & 8 deletions ooniapi/services/oonifindings/src/oonifindings/routers/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def list_oonifindings(
title=row.title,
event_type=row.event_type,
published=bool(row.published),
CCs=row.CCs,
ASNs=row.ASNs,
CCs=row.country_codes,
ASNs=row.asns,
domains=row.domains,
tags=row.tags,
test_names=row.test_names,
Expand Down Expand Up @@ -244,8 +244,8 @@ def get_oonifinding_by_id(
text=finding.text,
event_type=finding.event_type,
published=bool(finding.published),
CCs=finding.CCs,
ASNs=finding.ASNs,
CCs=finding.country_codes,
ASNs=finding.asns,
domains=finding.domains,
tags=finding.tags,
test_names=finding.test_names,
Expand Down Expand Up @@ -333,8 +333,8 @@ def create_oonifinding(
email_address=create_request.email_address,
event_type=create_request.event_type,
published=int(create_request.published),
CCs=create_request.CCs,
ASNs=create_request.ASNs,
country_codes=create_request.CCs,
asns=create_request.ASNs,
domains=create_request.domains,
tags=create_request.tags,
links=create_request.links,
Expand Down Expand Up @@ -393,8 +393,8 @@ def update_oonifinding(
oonifinding.text = update_request.text
oonifinding.event_type = update_request.event_type
oonifinding.published = int(update_request.published)
oonifinding.CCs = update_request.CCs
oonifinding.ASNs = update_request.ASNs
oonifinding.country_codes = update_request.CCs
oonifinding.asns = update_request.ASNs
oonifinding.domains = update_request.domains
oonifinding.tags = update_request.tags
oonifinding.links = update_request.links
Expand Down
4 changes: 2 additions & 2 deletions ooniapi/services/oonifindings/tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"published": 0,
"event_type": "incident",
"start_time": sample_start_time,
"ASNs": [],
"CCs": [
"asns": [],
"country_codes": [
"IN", "TZ",
],
"tags": [],
Expand Down

0 comments on commit af0efde

Please sign in to comment.