-
Notifications
You must be signed in to change notification settings - Fork 14
Update layout for projects #1305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
annavik
wants to merge
13
commits into
main
Choose a base branch
from
layout/projects
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8688e7f
layout: use compact gallery for projects
annavik 10292ce
chore: bump page size for projects to 40
annavik 8e449b7
feat: make it possible to see and change sort order from sort control
annavik 917161c
feat: add sorting to projects view
annavik 7082ce7
feat: make it possible to sort projects by name
annavik 0ac2147
layout: cleanup
annavik 5ba43b3
feat: add composite indexes for project activity sorting
mihow bd26d37
feat: sort projects by recent observations, identifications and jobs
mihow 9eb2626
feat: support per-field default sort order in sort control
mihow b5c99d6
feat: add recent activity sort options to projects view
mihow 8721f93
perf(projects): sort recent observations via deployment rollup
mihow 19e8608
fix(projects): make recent-captures sort live, null-safe and cheap to…
mihow 3ebf9a3
refactor(projects): use explicit sort labels for activity options
mihow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| from django.contrib.postgres.operations import AddIndexConcurrently | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| """Add the composite index that backs the project "recent identifications" sort. | ||
|
|
||
| Occurrence is large in production, so the index is built CONCURRENTLY to avoid | ||
| taking a write lock during deploy. This requires a non-atomic migration. | ||
|
|
||
| Building the index can take longer than a configured ``statement_timeout`` | ||
| (development sets 30s, see ``config/settings/local.py``; a production role may | ||
| set one too). ``CREATE INDEX CONCURRENTLY`` runs as a single statement and is | ||
| subject to that timeout, so we clear it for this connection before building. | ||
| """ | ||
|
|
||
| atomic = False | ||
|
|
||
| dependencies = [ | ||
| ("main", "0084_revoke_delete_job_from_roles"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| # Runtime SET overrides the startup "-c statement_timeout" option and | ||
| # persists for the rest of this (non-atomic) migration's connection. | ||
| migrations.RunSQL( | ||
| sql="SET statement_timeout = 0;", | ||
| reverse_sql=migrations.RunSQL.noop, | ||
| ), | ||
| AddIndexConcurrently( | ||
| model_name="occurrence", | ||
| index=models.Index(fields=["project", "-updated_at"], name="occur_proj_updated_desc_idx"), | ||
| ), | ||
| ] | ||
36 changes: 36 additions & 0 deletions
36
ami/main/migrations/0086_sourceimage_recent_capture_index.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| from django.contrib.postgres.operations import AddIndexConcurrently | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| """Add the index backing the project "recent captures" sort. | ||
|
|
||
| SourceImage is large in production (tens of millions of rows), so the index | ||
| is built CONCURRENTLY to avoid taking a write lock during deploy, which | ||
| requires a non-atomic migration. | ||
|
|
||
| A concurrent build on a table this size can exceed a configured | ||
| ``statement_timeout`` (development sets 30s, see ``config/settings/local.py``; | ||
| a production role may set one too). ``CREATE INDEX CONCURRENTLY`` runs as a | ||
| single statement subject to that timeout, so clear it for this connection | ||
| before building. | ||
| """ | ||
|
|
||
| atomic = False | ||
|
|
||
| dependencies = [ | ||
| ("main", "0085_project_activity_sort_indexes"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| # Runtime SET overrides the startup "-c statement_timeout" option and | ||
| # persists for the rest of this (non-atomic) migration's connection. | ||
| migrations.RunSQL( | ||
| sql="SET statement_timeout = 0;", | ||
| reverse_sql=migrations.RunSQL.noop, | ||
| ), | ||
| AddIndexConcurrently( | ||
| model_name="sourceimage", | ||
| index=models.Index(fields=["project", "-timestamp"], name="main_source_proj_ts_desc_idx"), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reset
statement_timeoutafter the concurrent index build.SET statement_timeout = 0is session-scoped, and this migration is non-atomic. Without a trailing reset, later migrations executed on the same connection inherittimeout=0, which silently disables that safeguard for the rest of the migrate run.Suggested fix
operations = [ # Runtime SET overrides the startup "-c statement_timeout" option and # persists for the rest of this (non-atomic) migration's connection. migrations.RunSQL( sql="SET statement_timeout = 0;", reverse_sql=migrations.RunSQL.noop, ), AddIndexConcurrently( model_name="occurrence", index=models.Index(fields=["project", "-updated_at"], name="occur_proj_updated_desc_idx"), ), + migrations.RunSQL( + sql="RESET statement_timeout;", + reverse_sql=migrations.RunSQL.noop, + ), ]📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.15.13)
[warning] 23-34: Mutable default value for class attribute
(RUF012)
🤖 Prompt for AI Agents