Skip to content

Commit bb208a9

Browse files
authored
Merge pull request #396 from scieloorg/fix_article_translations
Garante que seja obtido somente a traduções para seção e os idiomas quanto sub_article type=='translation'
2 parents d731597 + 4592066 commit bb208a9

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

airflow/dags/operations/sync_kernel_to_website_operations.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,13 @@ def _get_original_language(data: dict) -> str:
221221
def _get_languages(data: dict) -> List[str]:
222222
"""Recupera a lista de idiomas em que o artigo foi publicado"""
223223

224+
translations_type = ["translation",]
225+
224226
languages = [_get_original_language(data)]
225227

226228
for sub_article in _nestget(data, "sub_article"):
227-
languages.append(_nestget(sub_article, "article", 0, "lang", 0))
229+
if _nestget(sub_article, "article", 0, "type", 0) in translations_type:
230+
languages.append(_nestget(sub_article, "article", 0, "lang", 0))
228231

229232
return languages
230233

@@ -255,6 +258,8 @@ def _get_translated_titles(data: dict) -> Generator:
255258
def _get_translated_sections(data: dict) -> List[models.TranslatedSection]:
256259
"""Recupera a lista de seções traduzidas a partir do document front"""
257260

261+
translations_type = ["translation",]
262+
258263
sections = [
259264
models.TranslatedSection(
260265
**{
@@ -265,16 +270,18 @@ def _get_translated_sections(data: dict) -> List[models.TranslatedSection]:
265270
]
266271

267272
for sub_article in _nestget(data, "sub_article"):
268-
sections.append(
269-
models.TranslatedSection(
270-
**{
271-
"name": _nestget(
272-
sub_article, "article_meta", 0, "pub_subject", 0
273-
),
274-
"language": _nestget(sub_article, "article", 0, "lang", 0),
275-
}
273+
274+
if _nestget(sub_article, "article", 0, "type", 0) in translations_type:
275+
sections.append(
276+
models.TranslatedSection(
277+
**{
278+
"name": _nestget(
279+
sub_article, "article_meta", 0, "pub_subject", 0
280+
),
281+
"language": _nestget(sub_article, "article", 0, "lang", 0),
282+
}
283+
)
276284
)
277-
)
278285

279286
return sections
280287

0 commit comments

Comments
 (0)