Skip to content
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

Celery Agent Merging #3838

Merged
merged 30 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7058b75
celery task for processing agent merging in the background
acwhite211 Jul 25, 2023
4127884
remove circular model import
acwhite211 Jul 25, 2023
8e1c9ba
fix Agent import error
acwhite211 Jul 25, 2023
67d2bfc
prevent other Agent import errors
acwhite211 Jul 25, 2023
08bcd48
revised agent merging unit tests
acwhite211 Jul 25, 2023
ed786df
add status url
acwhite211 Jul 25, 2023
b62629b
fix progress in unit tests
acwhite211 Jul 25, 2023
32feaaf
Spmerging django migration
acwhite211 Jul 25, 2023
730d2ac
fix django migration issues by moving spmerging
acwhite211 Jul 25, 2023
1691c42
fix serialization error
acwhite211 Jul 25, 2023
dfb22ce
clean up status of failed merges
acwhite211 Jul 25, 2023
b6aa6f9
move starting notification to be inside the celery task
acwhite211 Jul 25, 2023
024c37a
fix progress closure
acwhite211 Jul 25, 2023
e2becf6
confirmed successful celery task execution
acwhite211 Jul 26, 2023
23f7928
catch unhandled errors and send notification
acwhite211 Jul 26, 2023
d2863f7
add additional information fields for spmerging
acwhite211 Jul 26, 2023
1d7e2f1
tmp github unit test fix
acwhite211 Jul 26, 2023
bef169e
github test database restart to fix unit testing
acwhite211 Jul 26, 2023
a395009
fix the test_SpecifyDB for unit testing
acwhite211 Jul 26, 2023
83c3f2b
remove previous test_SpecifyDB
acwhite211 Jul 26, 2023
ccd832d
try a different test database
acwhite211 Jul 26, 2023
9e74cc7
remove deleting test database action
acwhite211 Jul 26, 2023
d3fabc6
revert temp test db
acwhite211 Jul 26, 2023
a773bb7
add github action step for debugging
acwhite211 Jul 26, 2023
f48f2a6
debug db connection
acwhite211 Jul 26, 2023
f806b4f
fix debug db connection test
acwhite211 Jul 26, 2023
4185075
add verbosity to testing
acwhite211 Jul 26, 2023
3d9797b
move spmerging model definition outside of the specify app and into n…
acwhite211 Jul 26, 2023
81a82d8
revert GitHub actions to previous state
acwhite211 Jul 26, 2023
6c97b8a
add additional info to notifications
acwhite211 Jul 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions specifyweb/notifications/migrations/0003_spmerging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):

initial = True

dependencies = [
('specify', '__first__'),
('notifications', '0002_message_read'),
# migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Spmerging',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=256)),
('taskid', models.CharField(max_length=256)),
('mergingstatus', models.CharField(max_length=256)),
('timestampcreated', models.DateTimeField(default=django.utils.timezone.now)),
('timestampmodified', models.DateTimeField(auto_now=True)),
('createdbyagent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='specify.agent')),
('modifiedbyagent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='specify.agent')),
],
options={
'db_table': 'spmerging'
},
),
]
15 changes: 10 additions & 5 deletions specifyweb/specify/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ def test_replace_agents(self):
response = c.post(
f'/api/specify/agent/replace/{agent_2.id}/',
data=json.dumps({
'old_record_ids': [agent_1.id]
'old_record_ids': [agent_1.id],
'bg': False
}),
content_type='application/json'
)
Expand All @@ -597,7 +598,8 @@ def test_replace_agents(self):
response = c.post(
f'/api/specify/agent/replace/{agent_2.id}/',
data=json.dumps({
'old_record_ids': [agent_1.id]
'old_record_ids': [agent_1.id],
'bg': False
}),
content_type='application/json'
)
Expand Down Expand Up @@ -651,7 +653,8 @@ def test_record_recursive_merge(self):
f'/api/specify/agent/replace/{agent_2.id}/',
data=json.dumps({
'old_record_ids': [agent_1.id],
'new_record_data': None
'new_record_data': None,
'bg': False
}),
content_type='application/json'
)
Expand Down Expand Up @@ -702,7 +705,8 @@ def test_agent_address_replacement(self):
f'/api/specify/agent/replace/{agent_1.id}/',
data=json.dumps({
'old_record_ids': [agent_2.id],
'new_record_data': None
'new_record_data': None,
'bg': False
}),
content_type='application/json'
)
Expand Down Expand Up @@ -788,7 +792,8 @@ def test_agent_address_multiple_replacement(self):
}
],
'jobtitle': 'shardbearer'
}
},
'bg': False
}),
content_type='application/json')
self.assertEqual(response.status_code, 204)
Expand Down
18 changes: 18 additions & 0 deletions specifyweb/specify/merge_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.db import models
from django.utils import timezone

from specifyweb.specify import models as spmodels

Agent = getattr(spmodels, 'Agent')

class Spmerging(models.Model):
name = models.CharField(max_length=256)
taskid = models.CharField(max_length=256)
mergingstatus = models.CharField(max_length=256)
timestampcreated = models.DateTimeField(default=timezone.now)
timestampmodified = models.DateTimeField(auto_now=True)
createdbyagent = models.ForeignKey(Agent, null=True, on_delete=models.SET_NULL, related_name="+")
modifiedbyagent = models.ForeignKey(Agent, null=True, on_delete=models.SET_NULL, related_name="+")

class Meta:
db_table = 'spmerging'
1 change: 1 addition & 0 deletions specifyweb/specify/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
urlpatterns = [
# replace record
url(r'^specify/(?P<model_name>\w+)/replace/(?P<new_model_id>\d+)/$', views.record_merge),
url(r'^specify/merging_status/(?P<merge_id>\d+)/', views.merging_status),

# the main business data API
url(r'^specify_schema/openapi.json$', schema.openapi),
Expand Down
Loading
Loading