11import time
22
3+ from cid .locals import get_cid
34from django .conf import settings
45from django .db .models import F
56from django .http import Http404
@@ -831,20 +832,21 @@ def filter_queryset(self, _=None): # pylint: disable=too-many-locals,too-many-s
831832 reranker = self .request .GET .get ('reranker' , None ) in get_truthy_values () # enables reranker
832833 reranker = reranker and self .request .user .is_mapper_cross_encoder_group
833834 score_to_sort = 'search_rerank_score' if reranker else 'search_normalized_score'
835+ cid = get_cid ()
834836 results = []
835837 for row in rows :
836838 start_time = time .time ()
837839 search = ConceptFuzzySearch .search (
838840 row , target_repo_url , repo_params , include_retired ,
839841 is_semantic , num_candidates , k_nearest , map_config , faceted_criterion , locale_filter
840842 )
841- print (f"ES Search built in { time .time () - start_time } seconds" )
843+ print (f"[ { cid } ] ES Search built in { time .time () - start_time } seconds" )
842844 start_time = time .time ()
843845 search = search .params (track_total_hits = False , request_cache = True )
844846 es_search = CustomESSearch (search [start :end ], ConceptDocument )
845847 name = row .get ('name' ) or row .get ('Name' ) if reranker else None
846848 es_search .to_queryset (False , True , False , name , encoder_model )
847- print (f"ES Search (including reranker) executed in { time .time () - start_time } seconds" )
849+ print (f"[ { cid } ] ES Search (including reranker) executed in { time .time () - start_time } seconds" )
848850 start_time = time .time ()
849851 result = {'row' : row , 'results' : [], 'map_config' : map_config , 'filter' : filters }
850852 for concept in es_search .queryset :
@@ -859,12 +861,12 @@ def filter_queryset(self, _=None): # pylint: disable=too-many-locals,too-many-s
859861 data = serializer (concept , context = {'request' : self .request }).data
860862 data ['search_meta' ]['search_normalized_score' ] = normalized_score * 100
861863 result ['results' ].append (data )
862- print (f"Concepts serialized in { time .time () - start_time } seconds" )
864+ print (f"[ { cid } ] Concepts serialized in { time .time () - start_time } seconds" )
863865 start_time = time .time ()
864866 if 'results' in result :
865867 result ['results' ] = sorted (
866868 result ['results' ], key = lambda res : get (res , f'search_meta.{ score_to_sort } ' ), reverse = True )
867- print (f"Concepts sorted in { time .time () - start_time } seconds" )
869+ print (f"[ { cid } ] Concepts sorted in { time .time () - start_time } seconds" )
868870 results .append (result )
869871
870872 return results
0 commit comments