Skip to content

Commit

Permalink
Refactoing | extracted common code
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Apr 4, 2022
1 parent fb985e1 commit 5a9be79
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions core/collections/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,17 @@ def index_mappings(self):
else:
index_expansion_mappings.apply_async((self.id, ), queue='indexing')

def delete_references(self, references):
@staticmethod
def to_ref_list(references):
if isinstance(references, CollectionReference):
refs = [references]
elif isinstance(references, list):
refs = references
return [references]
if isinstance(references, list):
return references
else:
refs = references.all()
return references.all()

def delete_references(self, references):
refs = self.to_ref_list(references)

index_concepts = False
index_mappings = False
Expand Down Expand Up @@ -685,12 +689,7 @@ def delete_expressions(self, expressions):
batch_index_resources.apply_async(('mapping', mappings_filters), queue='indexing')

def add_references(self, references, index=True):
if isinstance(references, CollectionReference):
refs = [references]
elif isinstance(references, list):
refs = references
else:
refs = references.all()
refs = self.to_ref_list(references)

index_concepts = False
index_mappings = False
Expand Down

0 comments on commit 5a9be79

Please sign in to comment.