-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9843 from archesproject/dev/7.5.x
Update master with latest in 7.5.x
- Loading branch information
Showing
29 changed files
with
2,193 additions
and
1,564 deletions.
There are no files selected for viewing
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
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
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
29 changes: 29 additions & 0 deletions
29
arches/app/models/migrations/9648_add_empty_key_value_pairs_to_tiles.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,29 @@ | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("models", "9477_fix_for_spatial_view_dbf_function_edtf_displaying_null"), | ||
] | ||
|
||
def forwards_func(apps, schema_editor): | ||
TileModel = apps.get_model("models", "TileModel") | ||
Node = apps.get_model("models", "Node") | ||
|
||
for tile in TileModel.objects.filter(data={}, provisionaledits__isnull=False): | ||
for node in Node.objects.filter(nodegroup_id=tile.nodegroup_id): | ||
if not str(node.pk) in tile.data: | ||
tile.data[str(node.pk)] = None | ||
tile.save() | ||
|
||
def reverse_func(apps, schema_editor): | ||
TileModel = apps.get_model("models", "TileModel") | ||
|
||
for tile in TileModel.objects.filter(provisionaledits__isnull=False): | ||
if bool(tile.provisionaledits and not any(tile.data.values())): | ||
tile.data = {} | ||
tile.save() | ||
|
||
operations = [ | ||
migrations.RunPython(forwards_func, reverse_func), | ||
] |
70 changes: 70 additions & 0 deletions
70
arches/app/models/migrations/9670_improve_bulk_load_performance.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,70 @@ | ||
from django.db import migrations | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("models", "9648_add_empty_key_value_pairs_to_tiles"), | ||
] | ||
|
||
update_check_excess_tiles_trigger = """ | ||
create or replace procedure __arches_complete_bulk_load() AS | ||
$$ | ||
DECLARE | ||
cardinality_violations bigint; | ||
BEGIN | ||
alter table tiles enable trigger __arches_check_excess_tiles_trigger; | ||
alter table tiles enable trigger __arches_trg_update_spatial_attributes; | ||
END | ||
$$ | ||
language plpgsql; | ||
""" | ||
|
||
restore_check_excess_tiles_trigger = """ | ||
create or replace procedure __arches_complete_bulk_load() as | ||
$$ | ||
DECLARE | ||
cardinality_violations bigint; | ||
BEGIN | ||
alter table tiles enable trigger __arches_check_excess_tiles_trigger; | ||
alter table tiles enable trigger __arches_trg_update_spatial_attributes; | ||
if (not __arches_refresh_spatial_views()) then | ||
Raise EXCEPTION 'Unable to refresh spatial views'; | ||
end if; | ||
with cardinality_violations as (SELECT t.resourceinstanceid, | ||
t.nodegroupid, | ||
COALESCE(t.parenttileid::text, '') parent_tileid, | ||
count(*) | ||
FROM tiles t, | ||
node_groups ng | ||
WHERE t.nodegroupid = ng.nodegroupid | ||
AND ng.cardinality = '1' | ||
group by t.resourceinstanceid, t.nodegroupid, parent_tileid | ||
having count(*) > 1) | ||
select count(*) | ||
into cardinality_violations | ||
from cardinality_violations; | ||
if (cardinality_violations > 0) then | ||
Raise Exception 'Cardinality violations found. Run `%` to list violations', | ||
'select * from __arches_get_tile_cardinality_violations()'; | ||
else | ||
Raise Notice 'No cardinality violations found'; | ||
end if; | ||
END $$ | ||
language plpgsql; | ||
""" | ||
|
||
create_index_on_load_staging_tileid = """ | ||
CREATE INDEX IF NOT EXISTS load_staging_tileid ON load_staging (tileid); | ||
""" | ||
|
||
drop_index_on_load_staging_tileid = """ | ||
DROP INDEX IF EXISTS load_staging_tileid; | ||
""" | ||
|
||
operations = [ | ||
migrations.RunSQL(update_check_excess_tiles_trigger, restore_check_excess_tiles_trigger), | ||
migrations.RunSQL(create_index_on_load_staging_tileid, drop_index_on_load_staging_tileid), | ||
] |
Oops, something went wrong.