diff --git a/src/searchers.py b/src/searchers.py index 567235b..18e9b47 100644 --- a/src/searchers.py +++ b/src/searchers.py @@ -116,8 +116,8 @@ def exec_search(self, is_exact_search: bool, ignore_signature_match: bool, force_rematch: bool, - reference_date: datetime, - department: str): + department: str, + reference_date: datetime): search_results = self._search_all_terms( self._cast_term_list(term_list), dou_sections, @@ -160,7 +160,9 @@ def _search_all_terms(self, results = [r for r in results if self._really_matched(search_term, r.get('abstract'))] - self._department_matched(results, department) + if department: + results = [r for r in results + if department in r.get('hierarchyList')] self._render_section_descriptions(results) @@ -244,16 +246,6 @@ def _is_signature(self, search_term: str, abstract: str) -> bool: # ' JOSÉ `ANTONIO DE OLIVEIRA` MATOS' norm_abstract_without_start_name.startswith(norm_term)) ) - - def _department_matched(self, results: list, department: str) -> list: - """Verifica se o termo encontrado pela API realmente é igual ao - órgão de busca. Esta função é útil para filtrar resultados - retornardos pela API, mas que são específicas do órgão. - """ - - for result in results[:]: - if not department in result["hierarchyList"]: - results.remove(result) def _get_prior_and_matched_name(self, raw_html: str) -> Tuple[str, str]: groups = self.SPLIT_MATCH_RE.match(raw_html).groups()