diff options
author | 2021-07-11 22:56:17 +0200 | |
---|---|---|
committer | 2021-07-11 23:04:49 +0200 | |
commit | c52c606e6ae09291378c6eae17938d642dc2e463 (patch) | |
tree | 8c4ad3e710a3576dc414aba34cb59e6365b12c8f /pydis_site/hosts.py | |
parent | Merge pull request #552 from python-discord/cj/minor-adjustments (diff) |
Improvements & fixes to homepage repository display.
These changes mainly aim to prevent multiple concurrent requests from
deadlocking the table due to the lazy evaluation imposed by `objects.all()`,
and introduce some quality of life changes whilst doing so.
To prevent unwanted locks, the following is done:
- Instead of evaluating the first item of `objects.all()` only in order to
determine when the table was most recently updated, we query for the least
recent updated entry and use that instead. As we use `.first()`, the model
instance is loaded directly.
The following quality of life changes are introduced:
- Instead of manual "update or create" logic for repositories retrieved from
the API, use Django's `update_or_create` instead.
- Instead of manual bulk creation of entries on initial data retrieve, Django's
`bulk_create` method is used instead.
- To allow for local testing of this endpoint without having to manually set up
GitHub REST authorization, anonymous GitHub access is used when no
`GITHUB_TOKEN` is configured.
Diffstat (limited to 'pydis_site/hosts.py')
0 files changed, 0 insertions, 0 deletions