Skip to content

Commit

Permalink
Merge branch 'main' into feat/Tapis-v3-redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
rstijerina authored Jun 11, 2024
2 parents 0d923bc + ef085e4 commit ad76cc0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 48 deletions.
89 changes: 42 additions & 47 deletions designsafe/apps/data/management/commands/es_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,58 +29,53 @@ def add_arguments(self, parser):
parser.add_argument('--local', help='Remote role to index from, either staging or default', default="dev")

def handle(self, *args, **options):
HOSTS = settings.ES_CONNECTIONS[settings.DESIGNSAFE_ENVIRONMENT]['hosts']
password = getpass.getpass('Enter password for remote ES cluster ')
username = options.get('username')
remote = options.get('remote')
local = options.get('local')

local_es_client = elasticsearch.Elasticsearch(settings.ES_CONNECTIONS[local]['hosts'])
local_es_client = elasticsearch.Elasticsearch(settings.ES_CONNECTIONS[local]['hosts'],
timeout=300)
remote_es_client = elasticsearch.Elasticsearch(settings.ES_CONNECTIONS[remote]['hosts'],
**{'http_auth': "designsafe_{}:{}".format(remote, password)})
**{'http_auth': "designsafe_{}:{}".format(remote, password)},
timeout=300)
def reindex(source_index, target_index, query=None):
try:
response = elasticsearch.helpers.reindex(
client=remote_es_client,
target_client=local_es_client,
source_index=source_index,
target_index=target_index,
query=query,
)
logger.info(f"Reindexed {response} documents from {source_index} to {target_index}")
except elasticsearch.helpers.BulkIndexError as e:
logger.error(f"BulkIndexError: {e.errors}")
logger.error(f"Failed to reindex documents from {source_index} to {target_index}")
return False
return response

indexes = ["designsafe-{}-files",
"designsafe-{}-publications",
"designsafe-{}-publications-legacy",
"designsafe-{}-projects",
"designsafe-{}-rapid-events",
"designsafe-{}-rapid-event-types"
]

elasticsearch.helpers.reindex(
client=remote_es_client,
target_client=local_es_client,
source_index="designsafe-{}-files".format(remote),
target_index="designsafe-{}-files".format(local),
query={"query": {"prefix": {"path._exact": "/{}".format(username)}}}
)

elasticsearch.helpers.reindex(
client=remote_es_client,
target_client=local_es_client,
source_index="designsafe-{}-publications".format(remote),
target_index="designsafe-{}-publications".format(local)
)

elasticsearch.helpers.reindex(
client=remote_es_client,
target_client=local_es_client,
source_index="designsafe-{}-publications-legacy".format(remote),
target_index="designsafe-{}-publications-legacy".format(local)
)

elasticsearch.helpers.reindex(
client=remote_es_client,
target_client=local_es_client,
source_index="designsafe-{}-projects".format(remote),
target_index="designsafe-{}-projects".format(local)
)

elasticsearch.helpers.reindex(
client=remote_es_client,
target_client=local_es_client,
source_index="designsafe-{}-rapid-events".format(remote),
target_index="designsafe-{}-rapid-events".format(local)
)

elasticsearch.helpers.reindex(
client=remote_es_client,
target_client=local_es_client,
source_index="designsafe-{}-rapid-event-types".format(remote),
target_index="designsafe-{}-rapid-event-types".format(local)
)

logger.debug(remote_es_client.info())
failed_indexes = []
for index in indexes:
query = {"query": {"prefix": {"path._exact": "/{}".format(username)}}} if "files" in index else None
result = reindex(
source_index=index.format(remote),
target_index=index.format(local),
query=query
)
if not result:
failed_indexes.append(index.format(local))
logger.info("Finished indexing.")
if failed_indexes:
logger.error(f"Successfully reindex {len(indexes) - len(failed_indexes)}"
f" of {len(indexes)} indexes\n"
f"failed indexes are: {', '.join(failed_indexes)}\n"
f"(check logs above for errors related to failures)")
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ export default class RapidMainCtrl {
);
this.map = L.map('map', {
layers: [streets, satellite],
scrollWheelZoom: true
scrollWheelZoom: true,
minZoom: 2, // 2 typically prevents zooming out to far to see multiple earths
maxBounds: [
[-90, -180], // Southwest coordinates
[90, 180], // Northeast coordinates
]
});
this.map.setView([30.2672, -97.7431], 2);
this.map.zoomControl.setPosition('topright');
Expand Down

0 comments on commit ad76cc0

Please sign in to comment.