@@ -114,7 +114,7 @@ def get_unique_xpaths_from_notice_repository(mongodb_client: MongoClient) -> Lis
114114 :return:
115115 """
116116 notice_repository = NoticeRepository (mongodb_client = mongodb_client )
117- return notice_repository .collection .distinct ("xml_metadata. unique_xpaths" )
117+ return notice_repository .xml_metadata_repository . collection .distinct ("unique_xpaths" )
118118
119119
120120def get_unique_notice_id_from_notice_repository (mongodb_client : MongoClient ) -> List [str ]:
@@ -138,14 +138,14 @@ def get_minimal_set_of_xpaths_for_coverage_notices(notice_ids: List[str], mongod
138138 unique_notice_ids = notice_ids .copy ()
139139 notice_repository = NoticeRepository (mongodb_client = mongodb_client )
140140 while len (unique_notice_ids ):
141- tmp_result = list (notice_repository .collection .aggregate ([
142- {"$unwind" : "$xml_metadata. unique_xpaths" },
141+ tmp_result = list (notice_repository .xml_metadata_repository . collection .aggregate ([
142+ {"$unwind" : "$unique_xpaths" },
143143 {"$match" : {
144- "xml_metadata. unique_xpaths" : {"$nin" : minimal_set_of_xpaths },
144+ "unique_xpaths" : {"$nin" : minimal_set_of_xpaths },
145145 "ted_id" : {"$in" : unique_notice_ids }
146146 }
147147 },
148- {"$group" : {"_id" : "$xml_metadata. unique_xpaths" , "count" : {"$sum" : 1 },
148+ {"$group" : {"_id" : "$unique_xpaths" , "count" : {"$sum" : 1 },
149149 "notice_ids" : {"$push" : "$ted_id" }}},
150150 {"$sort" : {"count" : - 1 }},
151151 {"$limit" : 1 }
@@ -171,17 +171,17 @@ def get_minimal_set_of_notices_for_coverage_xpaths(notice_ids: List[str], mongod
171171 search_notices = notice_ids .copy ()
172172 notice_repository = NoticeRepository (mongodb_client = mongodb_client )
173173 while len (unique_xpaths ):
174- tmp_result = list (notice_repository .collection .aggregate ([
174+ tmp_result = list (notice_repository .xml_metadata_repository . collection .aggregate ([
175175 {"$match" : {
176- "_id " : {"$in" : search_notices }
176+ "ted_id " : {"$in" : search_notices }
177177 }
178178 },
179- {"$unwind" : "$xml_metadata. unique_xpaths" },
179+ {"$unwind" : "$unique_xpaths" },
180180 {"$match" : {
181- "xml_metadata. unique_xpaths" : {"$in" : unique_xpaths },
181+ "unique_xpaths" : {"$in" : unique_xpaths },
182182 }
183183 },
184- {"$group" : {"_id" : "$ted_id" , "count" : {"$sum" : 1 }, "xpaths" : {"$addToSet" : "$xml_metadata. unique_xpaths" }
184+ {"$group" : {"_id" : "$ted_id" , "count" : {"$sum" : 1 }, "xpaths" : {"$addToSet" : "$unique_xpaths" }
185185 }},
186186 {"$sort" : {"count" : - 1 }},
187187 {"$limit" : 1 }
@@ -204,8 +204,8 @@ def get_unique_notices_id_covered_by_xpaths(xpaths: List[str], mongodb_client: M
204204 :return:
205205 """
206206 notice_repository = NoticeRepository (mongodb_client = mongodb_client )
207- results = list (notice_repository .collection .aggregate ([
208- {"$match" : {"xml_metadata. unique_xpaths" : {"$in" : xpaths }}},
207+ results = list (notice_repository .xml_metadata_repository . collection .aggregate ([
208+ {"$match" : {"unique_xpaths" : {"$in" : xpaths }}},
209209 {
210210 "$group" : {"_id" : None ,
211211 "ted_ids" : {"$push" : "$ted_id" }
@@ -223,12 +223,11 @@ def get_unique_xpaths_covered_by_notices(notice_ids: List[str], mongodb_client:
223223 :return:
224224 """
225225 notice_repository = NoticeRepository (mongodb_client = mongodb_client )
226- results = notice_repository .collection .aggregate ([{"$match" : {"ted_id" : {"$in" : notice_ids }}}], allowDiskUse = True )
226+ results = notice_repository .xml_metadata_repository . collection .aggregate ([{"$match" : {"ted_id" : {"$in" : notice_ids }}}], allowDiskUse = True )
227227 unique_xpaths = set ()
228228 for result in results :
229- xml_metadata = result ["xml_metadata" ]
230- if xml_metadata is not None :
231- unique_xpaths .update (result ["xml_metadata" ]["unique_xpaths" ])
229+ if result ["unique_xpaths" ] is not None :
230+ unique_xpaths .update (result ["unique_xpaths" ])
232231 return list (unique_xpaths )
233232
234233
0 commit comments