wevote / WeVoteServer

We Vote's API application server written in Django/Python. Election data pulled from many sources, used by https://github.com/wevote/WebApp and https://github.com/wevote/WeVoteCordova and https://github.com/wevote/Campaigns.
https://api.wevoteusa.org
MIT License
50 stars 424 forks source link

Wv 452 update any uses of polling location objects all that could use readonly instead of hitting main database [TEAM REVIEW] #2662

Closed MadisonEvans94 closed 2 weeks ago

MadisonEvans94 commented 1 month ago

implemented control flow statements for all read operations in polling_location so that the 'readonly' db is utilized

There are a few other items that I noted that may need further review/second opinion:

def get_queryset(model, read_only=True):
    if read_only:
        return model.objects.using('readonly').all()
    else:
        return model.objects.all()

or possibly using DATABASE_ROUTES provided by django