-
Notifications
You must be signed in to change notification settings - Fork 1
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
1155 add a column to track the reindexing curator #1180
Open
Kirandawadi
wants to merge
12
commits into
dev
Choose a base branch
from
1155-add-a-column-to-track-the-reindexing-curator
base: dev
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
12 commits
Select commit
Hold shift + click to select a range
1447d19
Add 'Reindexing Curator' column (non-functioning)
Kirandawadi 4ff58d7
Fixed DataTable to work with new changes
Kirandawadi 11dfed8
Add "reindexing_curated_by" field to track Reindexing Curator
Kirandawadi 0bb0ccb
Changed NONE to None
Kirandawadi cf7d1f8
Removed hardcoded layout for SearchPanes
Kirandawadi 6c3d9c8
Merge branch 'dev' into 1155-add-a-column-to-track-the-reindexing-cur…
Kirandawadi ad4364b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8541c75
Merge branch 'dev' into 1155-add-a-column-to-track-the-reindexing-cur…
Kirandawadi 386ddaf
Maintain Reindexing History while Reindexing Curator is changed
Kirandawadi e0a9367
Track old reindexing curator
Kirandawadi 9ec2e45
Add ReindexingHistory model tests
Kirandawadi 150dfb7
Fix tests
Kirandawadi 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
27 changes: 27 additions & 0 deletions
27
sde_collections/migrations/0076_collection_reindexing_curated_by.py
This file contains 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,27 @@ | ||
# Generated by Django 4.2.9 on 2025-01-09 05:07 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("sde_collections", "0075_alter_collection_reindexing_status_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="collection", | ||
name="reindexing_curated_by", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
related_name="reindexing_curated_by", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
] |
28 changes: 28 additions & 0 deletions
28
sde_collections/migrations/0077_alter_collection_reindexing_curated_by.py
This file contains 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,28 @@ | ||
# Generated by Django 4.2.9 on 2025-01-09 05:12 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("sde_collections", "0076_collection_reindexing_curated_by"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="collection", | ||
name="reindexing_curated_by", | ||
field=models.ForeignKey( | ||
blank=True, | ||
default=None, | ||
null=True, | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
related_name="reindexing_curated_by", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
] |
27 changes: 27 additions & 0 deletions
27
sde_collections/migrations/0078_reindexinghistory_old_curator.py
This file contains 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,27 @@ | ||
# Generated by Django 4.2.9 on 2025-01-29 05:28 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("sde_collections", "0077_alter_collection_reindexing_curated_by"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="reindexinghistory", | ||
name="old_curator", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
related_name="old_curator", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
] |
This file contains 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 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 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,85 @@ | ||
# docker-compose -f local.yml run --rm django pytest -s sde_collections/tests/test_reindexing_history.py | ||
|
||
import pytest | ||
from django.contrib.auth import get_user_model | ||
|
||
from sde_collections.models.collection import Collection, ReindexingHistory | ||
from sde_collections.models.collection_choice_fields import ReindexingStatusChoices | ||
from sde_collections.tests.factories import CollectionFactory, UserFactory | ||
|
||
User = get_user_model() | ||
|
||
|
||
@pytest.mark.django_db | ||
class TestReindexingHistory: | ||
"""Test suite for ReindexingHistory functionality""" | ||
|
||
def setup_method(self): | ||
"""Setup test data""" | ||
self.collection = CollectionFactory() | ||
self.user1 = UserFactory() | ||
self.user2 = UserFactory() | ||
|
||
def test_reindexing_history_status_change(self): | ||
"""Should create history entry when reindexing status changes""" | ||
self.collection.reindexing_status = ReindexingStatusChoices.REINDEXING_NEEDED_ON_DEV | ||
self.collection.save() | ||
|
||
history = ReindexingHistory.objects.filter(collection=self.collection) | ||
assert history.count() == 1 | ||
assert history.first().reindexing_status == ReindexingStatusChoices.REINDEXING_NEEDED_ON_DEV | ||
assert history.first().old_status == ReindexingStatusChoices.REINDEXING_NOT_NEEDED | ||
|
||
def test_reindexing_history_curator_change(self): | ||
"""Should create history entry when curator changes""" | ||
self.collection.reindexing_curated_by = self.user1 | ||
self.collection.save() | ||
|
||
history = ReindexingHistory.objects.filter(collection=self.collection) | ||
assert history.count() == 1 | ||
assert history.first().curated_by == self.user1 | ||
assert history.first().old_curator is None | ||
|
||
def test_reindexing_history_both_changes(self): | ||
"""Should create history entry when both status and curator change""" | ||
self.collection.reindexing_status = ReindexingStatusChoices.REINDEXING_NEEDED_ON_DEV | ||
self.collection.reindexing_curated_by = self.user1 | ||
self.collection.save() | ||
|
||
history = ReindexingHistory.objects.filter(collection=self.collection) | ||
assert history.count() == 1 | ||
entry = history.first() | ||
assert entry.reindexing_status == ReindexingStatusChoices.REINDEXING_NEEDED_ON_DEV | ||
assert entry.old_status == ReindexingStatusChoices.REINDEXING_NOT_NEEDED | ||
assert entry.curated_by == self.user1 | ||
assert entry.old_curator is None | ||
|
||
def test_reindexing_history_multiple_changes(self): | ||
"""Should create multiple history entries for sequential changes""" | ||
# First change | ||
self.collection.reindexing_status = ReindexingStatusChoices.REINDEXING_NEEDED_ON_DEV | ||
self.collection.reindexing_curated_by = self.user1 | ||
self.collection.save() | ||
|
||
# Re-fetch the object | ||
self.collection = Collection.objects.get(id=self.collection.id) | ||
|
||
# Second change | ||
self.collection.reindexing_status = ReindexingStatusChoices.REINDEXING_FINISHED_ON_DEV | ||
self.collection.reindexing_curated_by = self.user2 | ||
self.collection.save() | ||
|
||
history = ReindexingHistory.objects.filter(collection=self.collection).order_by("created_at") | ||
assert history.count() == 2 | ||
|
||
first_entry = history[0] | ||
assert first_entry.reindexing_status == ReindexingStatusChoices.REINDEXING_NEEDED_ON_DEV | ||
assert first_entry.old_status == ReindexingStatusChoices.REINDEXING_NOT_NEEDED | ||
assert first_entry.curated_by == self.user1 | ||
assert first_entry.old_curator is None | ||
|
||
second_entry = history[1] | ||
assert second_entry.reindexing_status == ReindexingStatusChoices.REINDEXING_FINISHED_ON_DEV | ||
assert second_entry.old_status == ReindexingStatusChoices.REINDEXING_NEEDED_ON_DEV | ||
assert second_entry.curated_by == self.user2 | ||
assert second_entry.old_curator == self.user1 |
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.
write tests as well.