Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1595 | Removed migrate from old export path…
Browse files Browse the repository at this point in the history
… to new | remove repo old export path code
  • Loading branch information
snyaggarwal committed Aug 5, 2023
1 parent c73aaaa commit 2281dd2
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 37 deletions.
18 changes: 0 additions & 18 deletions core/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from .tasks import handle_save, handle_m2m_changed, seed_children_to_new_version, update_validation_schema, \
update_source_active_concepts_count, update_source_active_mappings_count


TRUTHY = get_truthy_values()


Expand Down Expand Up @@ -796,23 +795,6 @@ def is_exporting(self):

return False

def migrate_to_new_export_path(self, move=False): # needs to be deleted post migration to new export path # pragma: no cover # pylint: disable: line-too-long
from core.common.services import S3
for version in self.versions:
S3.rename(version.export_path, version.version_export_path, delete=move)

@cached_property
def export_path(self): # old export path, needs to be deleted post migration to new export path # pragma: no cover
last_update = self.last_child_update.strftime('%Y%m%d%H%M%S')
return self.generic_export_path(suffix=f"{last_update}.zip")

def generic_export_path(self, suffix='*'): # old export path, needs to be deleted post migration to new export path # pragma: no cover # pylint: disable: line-too-long
path = f"{self.parent_resource}/{self.mnemonic}_{self.version}."
if suffix:
path += suffix

return path

@cached_property
def version_export_path(self):
last_update = self.last_child_update.strftime('%Y-%m-%d_%H%M%S')
Expand Down
14 changes: 0 additions & 14 deletions core/common/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,6 @@ def exists(cls, key):

return True

@classmethod
def rename(cls, old_key, new_key, delete=False):
try:
resource = cls.__resource()
resource.meta.client.copy(
{'Bucket': settings.AWS_STORAGE_BUCKET_NAME, 'Key': old_key}, settings.AWS_STORAGE_BUCKET_NAME, new_key
)
if delete:
cls.delete_objects(old_key)
except (ClientError, NoCredentialsError):
return False

return True

@classmethod
def has_path(cls, prefix='/', delimiter='/'):
return len(cls.__fetch_keys(prefix, delimiter)) > 0
Expand Down
6 changes: 1 addition & 5 deletions core/sources/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from core.common.swagger_parameters import q_param, limit_param, sort_desc_param, sort_asc_param, exact_match_param, \
page_param, verbose_param, include_retired_param, updated_since_param, include_facets_header, compress_header
from core.common.tasks import export_source, index_source_concepts, index_source_mappings, delete_source
from core.common.utils import parse_boolean_query_param, compact_dict_by_values, to_parent_uri, get_truthy_values
from core.common.utils import parse_boolean_query_param, compact_dict_by_values, to_parent_uri
from core.common.views import BaseAPIView, BaseLogoView, ConceptContainerExtraRetrieveUpdateDestroyView, TaskMixin
from core.sources.constants import DELETE_FAILURE, DELETE_SUCCESS, VERSION_ALREADY_EXISTS
from core.sources.documents import SourceDocument
Expand Down Expand Up @@ -197,10 +197,6 @@ def get_object(self, queryset=None):
if version.should_set_active_mappings:
version.update_mappings_count()

truthy = get_truthy_values()
if self.request.user.is_staff and self.request.query_params.get('migrate_export_path', False) in truthy: # pragma: no cover # pylint: disable: line-too-long
instance.migrate_to_new_export_path(move=self.request.query_params.get('move', False) in truthy)

return instance

def get_permissions(self):
Expand Down

0 comments on commit 2281dd2

Please sign in to comment.