Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
feature: remove Aventri events from the search ElasticSearch query
Browse files Browse the repository at this point in the history
The ElasticSearch/Activity Stream feed for Aventri is currently disabled but will be re-enabled soon. However once it is re-enabled it will return all events from the Aventri API, in contrast to the original feed which did some filtering. This will cause undesired search results to appear on great.gov.uk if the ElasticSearch query remains as it is. Therefore this commit removes Aventri events from the ElasticSearch query and a separate commit will be pushed at a later stage to update the query with the relevant filters.
  • Loading branch information
abbas123456 committed Feb 4, 2021
1 parent 0c47a16 commit 4c1b163
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 39 deletions.
7 changes: 0 additions & 7 deletions search/helpers.py
Expand Up @@ -145,12 +145,6 @@ def format_query(query, page):
'query': 'dit:Service',
'boost': 20000
}
}},
{'match': {
'type': {
'query': 'dit:aventri:Event',
'boost': 10000
}
}}
],
'filter': [
Expand All @@ -164,7 +158,6 @@ def format_query(query, page):
'dit:Opportunity',
'dit:Market',
'dit:Service',
'dit:aventri:Event'
]
}}
]
Expand Down
7 changes: 0 additions & 7 deletions search/serializers.py
Expand Up @@ -20,18 +20,12 @@ def strip_html(result):
BeautifulSoup(html, "html.parser").findAll(text=True)
).rstrip()

def format_events_url(result):
if "dit:aventri:Event" in result['type']:
url = parse_url(result['url'])
result['url'] = build_events_url(url.request_uri)

def abridge_long_contents(result):
if 'content' in result:
result['content'] = Truncator(result['content']).chars(160)

def format_display_type(result):
mappings = {
'dit:aventri:Event': 'Event',
'dit:Opportunity': 'Export opportunity',
'Opportunity': 'Export opportunity',
'Market': 'Online marketplace',
Expand All @@ -54,7 +48,6 @@ def format_display_type(result):
# It also removes unneccessary \n added by the markdown library
for result in results:
strip_html(result)
format_events_url(result)
format_display_type(result)
abridge_long_contents(result)

Expand Down
7 changes: 0 additions & 7 deletions search/tests/test_helpers.py
Expand Up @@ -267,12 +267,6 @@ def test_format_query():
'query': 'dit:Service',
'boost': 20000
}
}},
{'match': {
'type': {
'query': 'dit:aventri:Event',
'boost': 10000
}
}}
],
'filter': [
Expand All @@ -286,7 +280,6 @@ def test_format_query():
'dit:Opportunity',
'dit:Market',
'dit:Service',
'dit:aventri:Event'
]
}}
]
Expand Down
18 changes: 0 additions & 18 deletions search/tests/test_serializers.py
Expand Up @@ -78,18 +78,6 @@ def test_parse_search_results():
'title': 'Test No URL',
'content': 'Here is the content'
}
}, {
'_index': 'objects__feed_id_first_feed__date_2019',
'_type': '_doc',
'_id': 'dit:exportOpportunities:Event:1',
'_score': 0.18232156,
'_source': {
'type': ['Document', 'dit:aventri:Event'],
'title': 'Test Event URL Parsing',
'content': 'Great event',
'url': 'https://eu.eventscloud.com\
/ehome/index.php?eventid=200188836&'
}
}]
}
}
Expand Down Expand Up @@ -122,10 +110,4 @@ def test_parse_search_results():
'type': 'Article',
'title': 'Test No URL',
'content': 'Here is the content',
}, {
'type': 'Event',
'title': 'Test Event URL Parsing',
'content': 'Great event',
'url': 'https://www.events.great.gov.uk/\
ehome/index.php?eventid=200188836&'
}]

0 comments on commit 4c1b163

Please sign in to comment.