Skip to content

Commit

Permalink
Schema updates
Browse files Browse the repository at this point in the history
- Associate officers with units, not agencies
- Add website url to review boards
- Differenciate command posts from standard officer employment
- Rename officer associations (investigators, commanders, etc.)
Update OAS README
  • Loading branch information
DMalone87 committed Sep 5, 2024
1 parent 8ad9b55 commit fe53c17
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 41 deletions.
31 changes: 24 additions & 7 deletions oas/2.0/agencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,20 @@ components:
allOf:
- $ref: "#/components/schemas/BaseUnit"
- type: "object"
properties:
commander_uid:
type: "string"
description: "The UID of the unit's current commander."
required:
- name
UpdateUnit:
allOf:
- $ref: "#/components/schemas/BaseUnit"
- $ref: "#/components/schemas/BaseUnit"
- type: object
properties:
commander_uid:
type: string
description: The UID of the unit's current commander.
BaseUnit:
type: object
description: "Base properties for a unit"
Expand All @@ -365,9 +374,6 @@ components:
zip:
type: "string"
description: "Zip code of the unit"
commander:
type: "string"
description: "The Officer UID of the unit's commander"
Unit:
allOf:
- $ref: "#/components/schemas/BaseUnit"
Expand All @@ -376,6 +382,15 @@ components:
uid:
type: "string"
description: "Unique identifier for the unit"
commander:
allOf:
- $ref: officers.yaml#/components/schemas/Officer
- type: object
description: The current commander of the unit.
commander_history_url:
type: string
description: -|
URL that returns the past commanders of the unit and the period of their respective commands.
agency_url:
type: "string"
description: "URL to get the agency that this unit belongs to."
Expand All @@ -396,6 +411,7 @@ components:
required:
- officer_uid
- badge_number
- unit_uid
properties:
officer_uid:
type: "string"
Expand All @@ -417,9 +433,10 @@ components:
highest_rank:
type: "string"
description: "The highest rank the officer has held during their employment."
currently_employed:
type: "boolean"
description: "Whether the officer is currently employed by this agency."
commander:
type: boolean
description: -|
If true, this officer will be added as the commander of the unit for the specified time period.
AddOfficerList:
type: object
required:
Expand Down
10 changes: 5 additions & 5 deletions oas/2.0/complaints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,6 @@ components:
- $ref: "#/components/schemas/BaseComplaint"
- type: object
properties:
source_uid:
type: "string"
description: "The UID of the partner that reported the complaint."
civilian_review_board_uid:
type: "string"
description: "The UID of the civilian review board that reviewed the complaint."
Expand Down Expand Up @@ -395,7 +392,7 @@ components:
- $ref: "#/components/schemas/BaseInvestigation"
- type: object
properties:
officer_uid:
investigator_uid:
type: "string"
description: "The UID of the officer who preformed the investigation."
Investigation:
Expand All @@ -406,7 +403,7 @@ components:
uid:
type: "string"
description: "Unique identifier for the investigation."
officer:
investigator:
allOf:
- $ref: officers.yaml#/components/schemas/Officer
- type: "object"
Expand Down Expand Up @@ -447,6 +444,9 @@ components:
state:
type: "string"
description: "The state the review board is located in."
url:
type: string
description: The website URL for the review board.
Attachemnts:
type: "object"
properties:
Expand Down
17 changes: 6 additions & 11 deletions oas/2.0/officers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,16 @@ components:
description: "The badge number of the officer"
highest_rank:
type: "string"
description: "The highest rank the officer has held during their employment."
currently_employed:
type: "boolean"
description: "Whether the officer is currently employed by this agency."
description: "The highest rank the officer has held during this employment."
commander:
type: boolean
description: Indicates that the officer commanded the unit during this employment.
AddEmployment:
allOf:
- $ref: "#/components/schemas/BaseEmployment"
- type: "object"
- required:
- agency_uid
- unit_uid
- badge_number
AddEmploymentFailed:
type: object
Expand All @@ -221,17 +221,12 @@ components:
properties:
agencies:
type: "array"
description: "The agencies to add to the officer's employment history."
description: "The units to add to the officer's employment history."
items:
$ref: "#/components/schemas/AddEmployment"
Employment:
allOf:
- $ref: "#/components/schemas/BaseEmployment"
- type: "object"
- properties:
uid:
type: "string"
description: "The uid of the employment record"
AddEmploymentResponse:
type: object
required:
Expand Down
14 changes: 7 additions & 7 deletions oas/pydantic/agencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ class Agency(BaseAgency, BaseModel):


class CreateUnit(BaseUnit, BaseModel):
name: Optional[str] = Field(None, description="Name of the unit")
name: str = Field(..., description="Name of the unit")
website_url: Optional[str] = Field(None, description="Website of the unit")
phone: Optional[str] = Field(None, description="Phone number of the unit")
email: Optional[str] = Field(None, description="Email of the unit")
description: Optional[str] = Field(None, description="Description of the unit")
address: Optional[str] = Field(None, description="Street address of the unit")
zip: Optional[str] = Field(None, description="Zip code of the unit")
commander: Optional[str] = Field(None, description="The Officer UID of the unit's commander")
commander_uid: Optional[str] = Field(None, description="The UID of the unit's current commander.")


class UpdateUnit(BaseUnit, BaseModel):
Expand All @@ -79,7 +79,7 @@ class UpdateUnit(BaseUnit, BaseModel):
description: Optional[str] = Field(None, description="Description of the unit")
address: Optional[str] = Field(None, description="Street address of the unit")
zip: Optional[str] = Field(None, description="Zip code of the unit")
commander: Optional[str] = Field(None, description="The Officer UID of the unit's commander")
commander_uid: Optional[str] = Field(None, description="The UID of the unit's current commander.")


class BaseUnit(BaseModel):
Expand All @@ -91,7 +91,6 @@ class BaseUnit(BaseModel):
description: Optional[str] = Field(None, description="Description of the unit")
address: Optional[str] = Field(None, description="Street address of the unit")
zip: Optional[str] = Field(None, description="Zip code of the unit")
commander: Optional[str] = Field(None, description="The Officer UID of the unit's commander")


class Unit(BaseUnit, BaseModel):
Expand All @@ -102,8 +101,9 @@ class Unit(BaseUnit, BaseModel):
description: Optional[str] = Field(None, description="Description of the unit")
address: Optional[str] = Field(None, description="Street address of the unit")
zip: Optional[str] = Field(None, description="Zip code of the unit")
commander: Optional[str] = Field(None, description="The Officer UID of the unit's commander")
uid: Optional[str] = Field(None, description="Unique identifier for the unit")
commander: Optional[Officer] = Field(None, description="The current commander of the unit.")
commander_history_url: Optional[str] = Field(None, description="-| URL that returns the past commanders of the unit and the period of their respective commands.")
agency_url: Optional[str] = Field(None, description="URL to get the agency that this unit belongs to.")
officers_url: Optional[str] = Field(None, description="URL to get a list of officers for this unit.")

Expand All @@ -117,9 +117,9 @@ class AddOfficer(BaseModel):
earliest_employment: Optional[str] = Field(None, description="The earliest date of employment")
latest_employment: Optional[str] = Field(None, description="The latest date of employment")
badge_number: str = Field(..., description="The badge number of the officer")
unit_uid: Optional[str] = Field(None, description="The UID of the unit the officer is assigned to.")
unit_uid: str = Field(..., description="The UID of the unit the officer is assigned to.")
highest_rank: Optional[str] = Field(None, description="The highest rank the officer has held during their employment.")
currently_employed: Optional[bool] = Field(None, description="Whether the officer is currently employed by this agency.")
commander: Optional[bool] = Field(None, description="-| If true, this officer will be added as the commander of the unit for the specified time period.")


class AddOfficerList(BaseModel):
Expand Down
6 changes: 3 additions & 3 deletions oas/pydantic/complaints.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class UpdateComplaint(BaseComplaint, BaseModel):
outcome_of_contact: Optional[str] = Field(None, description="The outcome of the contact.")
civilian_witnesses: Optional[List[Civilian]] = Field(None, description="The civilian witnesses associated with the complaint.")
attachements: Optional[List[Attachemnts]] = Field(None, description="Documents and multimeida associated with the complaint.")
source_uid: Optional[str] = Field(None, description="The UID of the partner that reported the complaint.")
civilian_review_board_uid: Optional[str] = Field(None, description="The UID of the civilian review board that reviewed the complaint.")
police_witnesses: Optional[List[str]] = Field(None, description="The uid of any police witnesses associated with the complaint.")
allegations: Optional[List[CreateAllegation]] = Field(None, description="The allegations associated with the complaint.")
Expand Down Expand Up @@ -128,14 +127,14 @@ class BaseInvestigation(BaseModel):
class CreateInvestigation(BaseInvestigation, BaseModel):
start_date: Optional[str] = Field(None, description="The date the investigation started.")
end_date: Optional[str] = Field(None, description="The date the investigation ended.")
officer_uid: Optional[str] = Field(None, description="The UID of the officer who preformed the investigation.")
investigator_uid: Optional[str] = Field(None, description="The UID of the officer who preformed the investigation.")


class Investigation(BaseInvestigation, BaseModel):
start_date: Optional[str] = Field(None, description="The date the investigation started.")
end_date: Optional[str] = Field(None, description="The date the investigation ended.")
uid: Optional[str] = Field(None, description="Unique identifier for the investigation.")
officer: Optional[Officer] = Field(None, description="The officer who preformed the investigation.")
investigator: Optional[Officer] = Field(None, description="The officer who preformed the investigation.")


class Civilian(BaseModel):
Expand All @@ -149,6 +148,7 @@ class ReviewBoard(BaseModel):
name: Optional[str] = Field(None, description="The name of the review board.")
city: Optional[str] = Field(None, description="The city the review board is located in.")
state: Optional[str] = Field(None, description="The state the review board is located in.")
url: Optional[str] = Field(None, description="The website URL for the review board.")


class Attachemnts(BaseModel):
Expand Down
15 changes: 7 additions & 8 deletions oas/pydantic/officers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class BaseEmployment(BaseModel):
earliest_employment: Optional[str] = Field(None, description="The earliest date of employment")
latest_employment: Optional[str] = Field(None, description="The latest date of employment")
badge_number: Optional[str] = Field(None, description="The badge number of the officer")
highest_rank: Optional[str] = Field(None, description="The highest rank the officer has held during their employment.")
currently_employed: Optional[bool] = Field(None, description="Whether the officer is currently employed by this agency.")
highest_rank: Optional[str] = Field(None, description="The highest rank the officer has held during this employment.")
commander: Optional[bool] = Field(None, description="Indicates that the officer commanded the unit during this employment.")


class AddEmployment(BaseEmployment, BaseModel):
Expand All @@ -20,8 +20,8 @@ class AddEmployment(BaseEmployment, BaseModel):
earliest_employment: Optional[str] = Field(None, description="The earliest date of employment")
latest_employment: Optional[str] = Field(None, description="The latest date of employment")
badge_number: Optional[str] = Field(None, description="The badge number of the officer")
highest_rank: Optional[str] = Field(None, description="The highest rank the officer has held during their employment.")
currently_employed: Optional[bool] = Field(None, description="Whether the officer is currently employed by this agency.")
highest_rank: Optional[str] = Field(None, description="The highest rank the officer has held during this employment.")
commander: Optional[bool] = Field(None, description="Indicates that the officer commanded the unit during this employment.")


class AddEmploymentFailed(BaseModel):
Expand All @@ -30,7 +30,7 @@ class AddEmploymentFailed(BaseModel):


class AddEmploymentList(BaseModel):
agencies: Optional[List[AddEmployment]] = Field(None, description="The agencies to add to the officer's employment history.")
agencies: Optional[List[AddEmployment]] = Field(None, description="The units to add to the officer's employment history.")


class Employment(BaseEmployment, BaseModel):
Expand All @@ -40,9 +40,8 @@ class Employment(BaseEmployment, BaseModel):
earliest_employment: Optional[str] = Field(None, description="The earliest date of employment")
latest_employment: Optional[str] = Field(None, description="The latest date of employment")
badge_number: Optional[str] = Field(None, description="The badge number of the officer")
highest_rank: Optional[str] = Field(None, description="The highest rank the officer has held during their employment.")
currently_employed: Optional[bool] = Field(None, description="Whether the officer is currently employed by this agency.")
uid: Optional[str] = Field(None, description="The uid of the employment record")
highest_rank: Optional[str] = Field(None, description="The highest rank the officer has held during this employment.")
commander: Optional[bool] = Field(None, description="Indicates that the officer commanded the unit during this employment.")


class AddEmploymentResponse(BaseModel):
Expand Down

0 comments on commit fe53c17

Please sign in to comment.