-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding free-text-search to related barriers (#845)
* Adding free-text-search to related barriers * Rebase * Update and working search endpoint * format * format * Excluding archived barriers from inactive notification alerts (#858) Co-authored-by: santinomolinaro <santino.molinaro@mail> * Deleting cached barrier when creating and updating next steps items so they are reflected instantly on frontend (#861) Co-authored-by: santinomolinaro <santino.molinaro@mail> * TSS-1995: Move set_to_allowed_on into public barrier serializer (#862) * tss-1995: set_to_allowed expected on public_barrier serializer --------- Co-authored-by: abarolo <[email protected]> * updates * format * format * using the full text search on the search page * lint fix --------- Co-authored-by: santinomolinaro <santino.molinaro@mail> Co-authored-by: abarolo <[email protected]> Co-authored-by: abarolo <[email protected]> Co-authored-by: Uka Osim <[email protected]> Co-authored-by: Uka Osim <[email protected]>
- Loading branch information
1 parent
e7f2972
commit e8b9f2a
Showing
11 changed files
with
526 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
api/related_barriers/management/commands/run_search_related_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import logging | ||
|
||
from django.core.management import BaseCommand | ||
|
||
from api.barriers.models import Barrier | ||
from api.barriers.tasks import get_barriers_overseas_region | ||
from api.metadata.utils import get_sector | ||
from api.related_barriers.views import related_barriers_search | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
|
||
# ./manage.py run_search_related_test --searchterm 'Company called BARCLAYS PLC is affected by this barrier' | ||
|
||
help = "Test the related barriers engine with a search term" | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument("--searchterm", type=str, help="Search term to use") | ||
|
||
def handle(self, *args, **options): | ||
logger.critical("+++++++++") | ||
logger.critical("Start Test") | ||
logger.critical(options["searchterm"]) | ||
logger.critical("+++++++++") | ||
|
||
logger.critical("SCORES -----") | ||
response_data = related_barriers_search( | ||
"request_dummy", options["searchterm"], log_score=True | ||
) | ||
logger.critical("------------") | ||
|
||
for bar_id in response_data: # [-6:]: | ||
if bar_id != "search_term": | ||
logger.critical("-") | ||
barrier_detail = Barrier.objects.get(pk=bar_id) | ||
logger.critical("ID = " + str(bar_id)) | ||
logger.critical("TITLE = " + str(barrier_detail.title)) | ||
logger.critical("SUMMARY = " + str(barrier_detail.summary)) | ||
sectors_list = [ | ||
get_sector(sector)["name"] for sector in barrier_detail.sectors | ||
] | ||
logger.critical( | ||
"SECTORS = " | ||
+ str(get_sector(barrier_detail.main_sector)["name"]) | ||
+ " " | ||
+ str(sectors_list) | ||
) | ||
logger.critical( | ||
"COUNTRY = " | ||
+ str( | ||
get_barriers_overseas_region( | ||
barrier_detail.country, barrier_detail.trading_bloc | ||
) | ||
) | ||
) | ||
logger.critical("COMPANIES = " + str(barrier_detail.companies)) | ||
logger.critical( | ||
"OTHER COMPANIES = " + str(barrier_detail.related_organisations) | ||
) | ||
logger.critical( | ||
"STATUS SUMMARY = " + str(barrier_detail.status_summary) | ||
) | ||
logger.critical( | ||
"EST. RESOLUTION DATE = " | ||
+ str(barrier_detail.estimated_resolution_date) | ||
) | ||
logger.critical( | ||
"EXPORT DESC. = " + str(barrier_detail.export_description) | ||
) | ||
notes_list = [ | ||
note.text for note in barrier_detail.interactions_documents.all() | ||
] | ||
logger.critical("NOTES = " + str(notes_list)) | ||
logger.critical("-") | ||
|
||
logger.critical("+++++++++") | ||
logger.critical("End Test") | ||
logger.critical("+++++++++") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.