Skip to content

Commit

Permalink
comparison set validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jmensch1 committed Sep 3, 2020
1 parent a4cb368 commit 34c6c80
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
58 changes: 58 additions & 0 deletions server/.env-old
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

############################### API SETTINGS #############################

# Server
HOST=0.0.0.0
PORT=5000
DEBUG=0
ACCESS_LOG=1
AUTO_RELOAD=1
WORKERS=1
TMP_DIR=./__tmp__
UPDATE_ON_START=0

# Database
DATABASE_URL=postgresql://311_user:311_pass@db:5432/311_db
DATABASE_LOG_QUERIES=0

# Redis
REDIS_ENABLED=0
REDIS_URL=redis://redis:6379
REDIS_TTL_SECONDS=3600

# Picklebase
PICKLEBASE_ENABLED=1
PICKLEBASE_BATCH_SIZE=400000

# Picklecache
PICKLECACHE_ENABLED=1
PICKLECACHE_TTL_SECONDS=3600

# Socrata
SOCRATA_TOKEN=y1p3D2JbWkjKMXRKWM9rHqvEP
SOCRATA_BATCH_SIZE=50000

# Github
GITHUB_TOKEN=
GITHUB_ISSUES_URL=https://api.github.com/repos/hackforla/311-data-support/issues
GITHUB_PROJECT_URL=
GITHUB_SHA=DEVELOPMENT

# Slack
SLACK_WEBHOOK_URL=
SLACK_ERROR_CODES=[400, 500]

# Sendgrid
SENDGRID_API_KEY=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

######################### DOCKER-COMPOSE SETTINGS ########################

COMPOSE_PROJECT_NAME=311_data
DB_USER=311_user
DB_PASS=311_pass
DB_NAME=311_db
DB_HOST_PORT=5433
API_HOST_PORT=5000
API_RESTART_POLICY=no

################################ OVERRIDES ###############################
12 changes: 11 additions & 1 deletion server/api/code/lacity_data_api/routers/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from fastapi import responses
from fastapi import APIRouter
from pydantic import BaseModel, validator
from pydantic.dataclasses import dataclass

from services import status, map, visualizations, requests, comparison, github, email

Expand Down Expand Up @@ -65,10 +66,19 @@ class Cluster(BaseModel):
Clusters = List[Cluster]


class Set(dict):
@dataclass
class Set:
district: str
list: List[int]

@validator('district')
def district_is_valid(cls, v):
assert v in ['cc', 'nc'], 'district must be either "nc" or "cc".'
return v

def __getitem__(cls, item):
return getattr(cls, item)


class Comparison(BaseModel):
startDate: str
Expand Down
1 change: 1 addition & 0 deletions server/api/code/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

uvicorn.run(
"lacity_data_api.asgi:app",
reload=True,
host=os.getenv("APP_HOST", "127.0.0.1"),
port=int(os.getenv("APP_PORT", "5000")),
)

0 comments on commit 34c6c80

Please sign in to comment.