Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflows: check published papers for uk queue #4352

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading