Skip to content

Commit

Permalink
Merge pull request #4352 from PascalEgn/extend_uk_curation_queue
Browse files Browse the repository at this point in the history
workflows: check published papers for uk queue
  • Loading branch information
PascalEgn authored Sep 26, 2024
2 parents abe94b4 + 2015ef4 commit ff47b1c
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
9 changes: 9 additions & 0 deletions inspirehep/modules/workflows/tasks/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,15 @@ def check_if_core_and_uk_in_fulltext(obj, eng):
return regex.search(fulltext)


def check_if_uk_in_raw_affiliations(obj, eng):
raw_affs = get_value(obj.data, 'authors.raw_affiliations.value', [])
regex = re.compile(
r"\b(UK|United\s+Kingdom|England|Scotland|Northern\s+Ireland)\b", re.UNICODE | re.IGNORECASE)
for aff in chain.from_iterable(raw_affs):
if regex.search(aff):
return True


def load_record_from_hep(obj, wf):
control_number = obj.data['control_number']
pid_type = get_pid_type_from_schema(obj.data['$schema'])
Expand Down
12 changes: 11 additions & 1 deletion inspirehep/modules/workflows/workflows/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
check_if_germany_in_fulltext,
check_if_germany_in_raw_affiliations,
link_institutions_with_affiliations,
check_if_core_and_uk_in_fulltext
check_if_core_and_uk_in_fulltext,
check_if_uk_in_raw_affiliations,
)

from inspirehep.modules.workflows.tasks.classifier import (
Expand Down Expand Up @@ -310,6 +311,15 @@
context_factory=curation_ticket_context,
ticket_id_key='curation_ticket_id',
),
),
IF(
check_if_uk_in_raw_affiliations,
create_ticket(
template='literaturesuggest/tickets/curation_core.html',
queue='UK_curation',
context_factory=curation_ticket_context,
ticket_id_key='curation_ticket_id',
),
)
]
)
Expand Down
57 changes: 56 additions & 1 deletion tests/unit/workflows/test_workflows_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from inspirehep.modules.workflows.actions import MatchApproval, MergeApproval
from mocks import MockEng, MockObj

from inspirehep.modules.workflows.tasks.actions import jlab_ticket_needed, load_from_source_data, \
from inspirehep.modules.workflows.tasks.actions import check_if_uk_in_raw_affiliations, jlab_ticket_needed, load_from_source_data, \
extract_authors_from_pdf, is_suitable_for_pdf_authors_extraction, is_fermilab_report, add_collection, \
check_if_france_in_fulltext, check_if_france_in_raw_affiliations, check_if_germany_in_fulltext, \
check_if_germany_in_raw_affiliations, check_if_core_and_uk_in_fulltext
Expand Down Expand Up @@ -746,3 +746,58 @@ def test_check_if_uk_in_fulltext_core_case_insensitive(mocked_get_document, app)
obj, eng)

assert uk_in_fulltext_and_core


def test_check_if_uk_in_affiliations(app):
obj = MagicMock()
obj.extra_data = {}
obj.data = {
'authors': [
{"full_name": "author 1",
"raw_affiliations": [{"value": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam, 91405, UK"}]

}
]
}
result = check_if_uk_in_raw_affiliations(obj, None)
assert result
obj.data = {
'authors': [
{"full_name": "author 1",
"raw_affiliations": [{"value": "Lorem ipsum dolor united kingdom amet, consetetur sadipscing elitr, sed diam, 91405"}]

}
]
}
result = check_if_uk_in_raw_affiliations(obj, None)
assert result
obj.data = {
'authors': [
{"full_name": "author 1",
"raw_affiliations": [{"value": "Lorem ipsum dolor sit amet, Scotland sadipscing elitr, sed diam, 91405"}]

}
]
}
result = check_if_uk_in_raw_affiliations(obj, None)
assert result
obj.data = {
'authors': [
{"full_name": "author 1",
"raw_affiliations": [{"value": "Lorem engLand dolor sit amet, sadipscing elitr, sed diam, 91405"}]

}
]
}
result = check_if_uk_in_raw_affiliations(obj, None)
assert result
obj.data = {
'authors': [
{"full_name": "author 1",
"raw_affiliations": [{"value": "Lorem ipsum dolor sit amet, Northern ireland, sed diam, 91405"}]

}
]
}
result = check_if_uk_in_raw_affiliations(obj, None)
assert result

0 comments on commit ff47b1c

Please sign in to comment.