Skip to content

Commit

Permalink
Add citations to officers, units, and agencies
Browse files Browse the repository at this point in the history
  • Loading branch information
DMalone87 committed Oct 30, 2024
1 parent 3bed2b7 commit 5a08ee8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
9 changes: 9 additions & 0 deletions backend/database/models/agency.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from backend.schemas import JsonSerializable, PropertyEnum
from backend.database.models.types.enums import State
from backend.database.models.source import Citation

from neomodel import (
StructuredNode,
Expand Down Expand Up @@ -29,6 +30,8 @@ class UnitMembership(StructuredRel, JsonSerializable):


class Unit(StructuredNode, JsonSerializable):
__hidden_properties__ = ["citations"]

uid = UniqueIdProperty()
name = StringProperty()
website_url = StringProperty()
Expand All @@ -51,12 +54,16 @@ class Unit(StructuredNode, JsonSerializable):
officers = RelationshipTo(
"backend.database.models.officer.Officer",
"MEMBER_OF", model=UnitMembership)
citations = RelationshipTo(
'backend.database.models.source.Source', "UPDATED_BY", model=Citation)

def __repr__(self):
return f"<Unit {self.name}>"


class Agency(StructuredNode, JsonSerializable):
__hidden_properties__ = ["citations"]

uid = UniqueIdProperty()
name = StringProperty()
website_url = StringProperty()
Expand All @@ -71,6 +78,8 @@ class Agency(StructuredNode, JsonSerializable):

# Relationships
units = RelationshipTo("Unit", "ESTABLISHED")
citations = RelationshipTo(
'backend.database.models.source.Source', "UPDATED_BY", model=Citation)

def __repr__(self):
return f"<Agency {self.name}>"
7 changes: 6 additions & 1 deletion backend/database/models/litigation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from backend.schemas import JsonSerializable, PropertyEnum
from backend.database.models.source import Citation
from neomodel import (
StructuredNode,
StringProperty,
Expand All @@ -14,6 +15,8 @@ class LegalCaseType(str, PropertyEnum):


class Litigation(StructuredNode, JsonSerializable):
__hidden_properties__ = ["citations"]

uid = UniqueIdProperty()
case_title = StringProperty()
docket_number = StringProperty()
Expand All @@ -31,6 +34,8 @@ class Litigation(StructuredNode, JsonSerializable):
documents = RelationshipTo("Document", "RELATED_TO")
dispositions = RelationshipTo("Disposition", "YIELDED")
defendants = RelationshipTo("Officer", "NAMED_IN")
citations = RelationshipTo(
'backend.database.models.source.Source', "UPDATED_BY", model=Citation)

def __repr__(self):
return f"<Litigation {self.uid}:{self.case_title}>"
Expand All @@ -43,7 +48,7 @@ class Document(StructuredNode, JsonSerializable):
url = StringProperty()


class Disposition(StructuredNode):
class Disposition(StructuredNode, JsonSerializable):
description = StringProperty()
date = DateProperty()
disposition = StringProperty()
4 changes: 4 additions & 0 deletions backend/database/models/officer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from backend.schemas import JsonSerializable
from backend.database.models.types.enums import State, Ethnicity, Gender
from backend.database.models.source import Citation

from neomodel import (
StructuredNode,
Expand Down Expand Up @@ -30,6 +31,7 @@ class Officer(StructuredNode, JsonSerializable):
"last_name", "suffix", "ethnicity",
"gender", "date_of_birth"
]
__hidden_properties__ = ["citations"]

uid = UniqueIdProperty()
first_name = StringProperty()
Expand All @@ -52,6 +54,8 @@ class Officer(StructuredNode, JsonSerializable):
'backend.database.models.complaint.Investigation', "LEAD_BY")
commands = Relationship(
'backend.database.models.agency.Unit', "COMMANDS")
citations = RelationshipTo(
'backend.database.models.source.Source', "UPDATED_BY", model=Citation)

def __repr__(self):
return f"<Officer {self.id}>"
11 changes: 11 additions & 0 deletions backend/database/models/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ def __repr__(self):
id={self.uid}>"


class Citation(StructuredRel, JsonSerializable):
uid = UniqueIdProperty()
date = DateTimeProperty(default=datetime.now())
url = StringProperty()
diff = StringProperty()

def __repr__(self):
"""Represent instance as a unique string."""
return f"<Citation {self.uid}>"


class Source(StructuredNode, JsonSerializable):
__property_order__ = [
"uid", "name", "url",
Expand Down

0 comments on commit 5a08ee8

Please sign in to comment.