-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fixes for 76 search_filters and create_spatial_views sql files #1356
Open
SDScandrettKint
wants to merge
8
commits into
archesproject:76_upgrade
Choose a base branch
from
k-int:1355_76_branch_sql_fixes
base: 76_upgrade
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 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1e979c5
Fixes for 76 search_filters and create_spatial_views sql files
SDScandrettKint 559c981
Add 0002 migration, remove preliminary search filter sql and sp view …
SDScandrettKint 0e49f74
remove search_overlays sql file
SDScandrettKint 67c315b
change filter from name to layerdefinitions
SDScandrettKint d10c9aa
Add migration for applying bng component
SDScandrettKint 68011ec
Updating bng type and config
SDScandrettKint bdeb035
Apply 7.6 migration dependencies and add run_before to ensure 0001 ha…
SDScandrettKint c2294cc
change BNG sortorder so appears first in search bar
SDScandrettKint 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 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,169 @@ | ||
from django.db import migrations, models | ||
from django.utils.translation import gettext as _ | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("arches_her", "0001_initial") | ||
] | ||
|
||
def add_map_layers(apps, schema_editor): | ||
MapLayer = apps.get_model("models", "MapLayer") | ||
|
||
# Add/update map layers previously in preliminary_sql/search_overlays.sql | ||
# Previously layers were added using random uuid1, so name is only primary identifier | ||
|
||
existing_map = MapLayer.objects.filter(layerdefinitions__contains=[{"source":"search-results-hashes"}]) | ||
if not existing_map: | ||
MapLayer.objects.update_or_create( | ||
maplayerid="ede8a6af-110a-4dab-9d0b-f0eccb4cef86", | ||
name="Search Results Heat Map", | ||
layerdefinitions=[ | ||
{ | ||
"source": "search-results-hashes", | ||
"paint": { | ||
"heatmap-intensity": ["interpolate", ["linear"], ["zoom"], 0, 1, 20, 5], | ||
"heatmap-weight": ["interpolate", ["linear"], ["get", "doc_count"], 0, 0, 6, 1], | ||
"heatmap-color": [ | ||
"interpolate", | ||
["linear"], | ||
["heatmap-density"], | ||
0, | ||
"#ffffb2", | ||
0.2, | ||
"#fed976", | ||
0.4, | ||
"#feb24c", | ||
0.6, | ||
"#fd8d3c", | ||
0.8, | ||
"#f03b20", | ||
0.9, | ||
"#fff", | ||
1, | ||
"#bd0026", | ||
], | ||
"heatmap-radius": ["interpolate", ["linear"], ["zoom"], 0, 2, 9, 40, 15, 90, 20, 190], | ||
"heatmap-opacity": 0.6, | ||
}, | ||
"minzoom": 9, | ||
"maxzoom": 17, | ||
"type": "heatmap", | ||
"id": "search-results-heat", | ||
} | ||
], | ||
isoverlay=True, | ||
icon="ion-search", | ||
activated=True, | ||
addtomap=False, | ||
searchonly=True, | ||
sortorder=0, | ||
ispublic=True, | ||
) | ||
|
||
existing_map = MapLayer.objects.filter(layerdefinitions__contains=[{"source":"search-results-points"}]) | ||
if not existing_map: | ||
MapLayer.objects.update_or_create( | ||
maplayerid="77ec30f0-3dda-499a-a126-c67d41f7ba3a", | ||
name="Map Markers", | ||
layerdefinitions=[ | ||
{ | ||
"layout": {"icon-image": "marker-15", "icon-allow-overlap": True, "icon-offset": [0, -6], "icon-size": 1}, | ||
"source": "search-results-points", | ||
"filter": ["all", ["==", "$type", "Point"], ["!=", "highlight", True]], | ||
"paint": {}, | ||
"type": "symbol", | ||
"id": "search-results-points-markers", | ||
}, | ||
{ | ||
"layout": {"icon-image": "marker-15", "icon-allow-overlap": True, "icon-offset": [0, -6], "icon-size": 1.3}, | ||
"source": "search-results-points", | ||
"filter": ["all", ["==", "$type", "Point"], ["==", "highlight", True]], | ||
"paint": {}, | ||
"type": "symbol", | ||
"id": "search-results-points-markers-highlighted", | ||
}, | ||
{ | ||
"layout": {"visibility": "visible"}, | ||
"source": "search-results-points", | ||
"filter": ["all", ["==", "$type", "Point"], ["==", "highlight", True]], | ||
"paint": {"circle-translate": [0, -25], "circle-color": "rgba(0,0,0,0)", "circle-radius": 16}, | ||
"type": "circle", | ||
"id": "search-results-points-markers-point-highlighted", | ||
}, | ||
{ | ||
"layout": {"visibility": "visible"}, | ||
"source": "search-results-points", | ||
"filter": ["all", ["==", "$type", "Point"]], | ||
"paint": {"circle-translate": [0, -16], "circle-color": "rgba(0,0,0,0)", "circle-radius": 11}, | ||
"type": "circle", | ||
"id": "search-results-points-markers-point", | ||
}, | ||
], | ||
isoverlay=True, | ||
icon="ion-location", | ||
activated=True, | ||
addtomap=True, | ||
searchonly=True, | ||
sortorder=0, | ||
ispublic=True, | ||
) | ||
|
||
existing_map = MapLayer.objects.filter(layerdefinitions__contains=[{"source":"search-results-hex"}]) | ||
if not existing_map: | ||
MapLayer.objects.update_or_create( | ||
maplayerid="604bd229-85ca-42db-a7ef-eb2ed81e8537", | ||
name="Hex", | ||
layerdefinitions=[ | ||
{ | ||
"layout": {}, | ||
"source": "search-results-hex", | ||
"filter": ["==", "id", ""], | ||
"paint": { | ||
"fill-extrusion-color": "#54278f", | ||
"fill-extrusion-height": {"property": "doc_count", "type": "exponential", "stops": [[0, 0], [500, 5000]]}, | ||
"fill-extrusion-opacity": 0.85, | ||
}, | ||
"type": "fill-extrusion", | ||
"id": "search-results-hex-outline-highlighted", | ||
}, | ||
{ | ||
"layout": {}, | ||
"source": "search-results-hex", | ||
"filter": ["all", [">", "doc_count", 0]], | ||
"paint": { | ||
"fill-extrusion-color": { | ||
"property": "doc_count", | ||
"stops": [[1, "#f2f0f7"], [5, "#cbc9e2"], [10, "#9e9ac8"], [20, "#756bb1"], [50, "#54278f"]], | ||
}, | ||
"fill-extrusion-height": {"property": "doc_count", "type": "exponential", "stops": [[0, 0], [500, 5000]]}, | ||
"fill-extrusion-opacity": 0.5, | ||
}, | ||
"type": "fill-extrusion", | ||
"id": "search-results-hex", | ||
}, | ||
], | ||
isoverlay=True, | ||
icon="ion-funnel", | ||
activated=True, | ||
addtomap=False, | ||
searchonly=True, | ||
sortorder=0, | ||
ispublic=True, | ||
) | ||
|
||
def remove_map_layers(apps, schema_editor): | ||
MapLayer = apps.get_model("models", "MapLayer") | ||
|
||
for map_layers in MapLayer.objects.filter(name__in=[ | ||
"Search Results Heat Map", | ||
"Map Markers", | ||
"Hex" | ||
]): | ||
map_layers.delete() | ||
|
||
|
||
operations = [ | ||
migrations.RunPython(add_map_layers, remove_map_layers), | ||
] |
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,73 @@ | ||
from django.db import migrations, models | ||
from django.utils.translation import gettext as _ | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("arches_her", "0002_move_pkg_sql"), | ||
("models", "10804_core_search_filters"), | ||
] | ||
|
||
def add_bng_component_to_search_view(apps, scheme_editor): | ||
SearchComponent = apps.get_model("models", "SearchComponent") | ||
|
||
standard_search_view = SearchComponent.objects.get(searchcomponentid="69695d63-6f03-4536-8da9-841b07116381") | ||
standard_search_view.config["linkedSearchFilters"].append( | ||
{ | ||
"componentname": "bng-filter", | ||
"layoutSortorder": 14, | ||
"searchcomponentid": "25ca3536-9eb4-4fd5-b2a5-badfd9a266de" | ||
} | ||
) | ||
standard_search_view.save() | ||
|
||
def remove_bng_component_from_search_view(apps, scheme_editor): | ||
SearchComponent = apps.get_model("models", "SearchComponent") | ||
|
||
standard_search_view = SearchComponent.objects.get(searchcomponentid="69695d63-6f03-4536-8da9-841b07116381") | ||
for search_filter in standard_search_view.config["linkedSearchFilters"]: | ||
if search_filter["searchcomponentid"] == "25ca3536-9eb4-4fd5-b2a5-badfd9a266de": | ||
standard_search_view.config["linkedSearchFilters"].remove(search_filter) | ||
standard_search_view.save() | ||
|
||
|
||
def apply_bng_layout_type(apps, scheme_editor): | ||
SearchComponent = apps.get_model("models", "SearchComponent") | ||
|
||
SearchComponent.objects.update_or_create( | ||
searchcomponentid="25ca3536-9eb4-4fd5-b2a5-badfd9a266de", | ||
name="BNG Filter", | ||
icon="fa fa-compass", | ||
modulename="bng-filter.py", | ||
classname="BngFilter", | ||
componentpath="views/components/search/bng-filter", | ||
componentname="bng-filter", | ||
defaults={ | ||
"config":{"layoutType": "popup"}, # add previous layout type into new config | ||
"type":"bng-filter-type" # previously "popup" which has now moved | ||
} | ||
) | ||
|
||
def revert_bng_layout_type(apps, scheme_editor): | ||
SearchComponent = apps.get_model("models", "SearchComponent") | ||
|
||
# Revert BNG search component to how it used to be | ||
SearchComponent.objects.update_or_create( | ||
searchcomponentid="25ca3536-9eb4-4fd5-b2a5-badfd9a266de", | ||
name="BNG Filter", | ||
icon="fa fa-compass", | ||
modulename="bng-filter.py", | ||
classname="BngFilter", | ||
componentpath="views/components/search/bng-filter", | ||
componentname="bng-filter", | ||
defaults={ | ||
"config":{}, | ||
"type":"popup" | ||
} | ||
) | ||
|
||
operations = [ | ||
migrations.RunPython(add_bng_component_to_search_view, remove_bng_component_from_search_view), | ||
migrations.RunPython(apply_bng_layout_type, revert_bng_layout_type) | ||
] |
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.
I think this
10804_core_search_filters
dependency may cause problems because it is already a dependency of another arches migration,11117_add_bulk_concept_editor
.I think it should probably be changed to the last migration in arches 7.6 (
11499_add_editlog_resourceinstance_idx
) and moved to be the first dependency of0002_move_pkg_sql.py
. That way you finish Arches 7.6 migrations, and then resume the arches_her migrations at0002_move_pkg_sql
.In other words, make sure Arches updates to
11499_add_editlog_resourceinstance_idx
before0002_move_pkg_sql
runs, then run0003_add_bng_search_view
.