Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1126 | fixing source/collection summary sav…
Browse files Browse the repository at this point in the history
…e tasks
  • Loading branch information
snyaggarwal committed Nov 23, 2021
1 parent aaf346f commit e4ec5fc
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions core/common/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,37 +501,41 @@ def index_source_mappings(source_id):
def update_source_active_concepts_count(source_id):
from core.sources.models import Source
source = Source.objects.filter(id=source_id).first()
before_active_concepts = source.active_concepts
source.set_active_concepts()
if before_active_concepts != source.active_concepts:
source.save(update_fields=['active_concepts'])
if source:
before_active_concepts = source.active_concepts
source.set_active_concepts()
if before_active_concepts != source.active_concepts:
source.save(update_fields=['active_concepts'])


@app.task
def update_source_active_mappings_count(source_id):
from core.sources.models import Source
source = Source.objects.filter(id=source_id).first()
before_active_mappings = source.active_mappings
source.set_active_mappings()
if before_active_mappings != source.active_mappings:
source.save(update_fields=['active_mappings'])
if source:
before_active_mappings = source.active_mappings
source.set_active_mappings()
if before_active_mappings != source.active_mappings:
source.save(update_fields=['active_mappings'])


@app.task
def update_collection_active_concepts_count(collection_id):
from core.collections.models import Collection
collection = Collection.objects.filter(id=collection_id).first()
before_active_concepts = collection.active_concepts
collection.set_active_concepts()
if before_active_concepts != collection.active_concepts:
collection.save(update_fields=['active_concepts'])
if collection:
before_active_concepts = collection.active_concepts
collection.set_active_concepts()
if before_active_concepts != collection.active_concepts:
collection.save(update_fields=['active_concepts'])


@app.task
def update_collection_active_mappings_count(collection_id):
from core.collections.models import Collection
collection = Collection.objects.filter(id=collection_id).first()
before_active_mappings = collection.active_mappings
collection.set_active_mappings()
if before_active_mappings != collection.active_mappings:
collection.save(update_fields=['active_mappings'])
if collection:
before_active_mappings = collection.active_mappings
collection.set_active_mappings()
if before_active_mappings != collection.active_mappings:
collection.save(update_fields=['active_mappings'])

0 comments on commit e4ec5fc

Please sign in to comment.