Skip to content

Commit

Permalink
[EDS-606][EDS-608][EDS-613] Use "experimental" query as default for n…
Browse files Browse the repository at this point in the history
…ame searches (#122)

* Make the new "experimental" search mode the default for name searches

* [EDS-613] Fix nesting of footer in the DOM

* Remove unnecessary leading indent in footer.html

* Remove deprecated name query generation from query_generator.py

* Remove deprecated name query generation from query_generator.py

* [Bot] Update version to 2.1.0

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Thomas Thorogood and github-actions[bot] authored Oct 28, 2021
1 parent 0eae8ca commit 901a324
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 653 deletions.
10 changes: 0 additions & 10 deletions husky_directory/models/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,3 @@ class PopulationType(Enum):
class ResultDetail(Enum):
full = "full"
summary = "summary"


class SearchType(Enum):
# Old-school cool. It's inefficient but
# very explicit.
classic = "classic"

# In active development, constantly striving to
# provide more relevant results, faster!
experimental = "experimental"
4 changes: 1 addition & 3 deletions husky_directory/models/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from husky_directory.models.base import DirectoryBaseModel
from husky_directory.models.common import UWDepartmentRole
from husky_directory.models.enum import PopulationType, ResultDetail, SearchType
from husky_directory.models.enum import PopulationType, ResultDetail

# There is no direct dependency on the model here, we only need it for type checking;
# this protects us from accidentally creating a cyclic dependency between the modules.
Expand Down Expand Up @@ -59,7 +59,6 @@ class SearchDirectoryFormInput(DirectoryBaseModel):
render_query: Optional[str]
render_population: Optional[PopulationType]
render_length: Optional[ResultDetail]
search_type: SearchType = SearchType.classic

include_test_identities: bool = False # Not currently supported

Expand Down Expand Up @@ -136,7 +135,6 @@ class SearchDirectoryInput(DirectoryBaseModel):
population: PopulationType = PopulationType.employees
include_test_identities: bool = False
person_href: Optional[str]
search_type: SearchType = SearchType.classic

@classmethod
def search_methods(cls) -> List[str]:
Expand Down
369 changes: 1 addition & 368 deletions husky_directory/services/query_generator.py

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions husky_directory/services/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from flask_injector import request
from injector import inject

from husky_directory.models.enum import AffiliationState, SearchType
from husky_directory.models.enum import AffiliationState
from husky_directory.models.pws import (
ListPersonsInput,
ListPersonsOutput,
Expand Down Expand Up @@ -118,7 +118,9 @@ def search_directory_experimental(
pws_output = self._pws.get_explicit_href(
pws_output.next.href, output_type=ListPersonsOutput
)
self.reducer.reduce_output(pws_output, request_input.name, results)
results = self.reducer.reduce_output(
pws_output, request_input.name, results
)
statistics.aggregate(pws_output.request_statistics)

statistics.num_duplicates_found = self.reducer.duplicate_hit_count
Expand Down Expand Up @@ -154,9 +156,6 @@ def search_directory_classic(
scenarios: List[DirectoryQueryScenarioOutput] = []
scenario_description_indexes: Dict[str, int] = {}

if request_input.name:
statistics.num_user_search_tokens = len(request_input.name.split())

for generated in self.query_generator.generate(request_input):
self.logger.debug(
f"Querying: {generated.description} with "
Expand Down Expand Up @@ -211,12 +210,10 @@ def search_directory(
and returns a DirectoryQueryScenarioOutput."""

if (
SearchType(request_input.search_type) == SearchType.experimental
# Only name search is implemented in experimental mode right now.
and request_input.name
request_input.name
# Wildcard searches are already accounted for in "classic" mode.
and "*" not in request_input.name
):
return self.search_directory_experimental(request_input)

return self.search_directory_classic(request_input)
1 change: 1 addition & 0 deletions husky_directory/settings/base.dotenv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FLASK_ENV=development
UWCA_CERT_NAME=uwca
UWCA_CERT_PATH=/app/certificates
PWS_HOST=https://it-wseval1.s.uw.edu
Expand Down
2 changes: 1 addition & 1 deletion husky_directory/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ <h2 style="margin-top:40px;">UW Directory</h2>
<hr/>
{% block content %}{% endblock %}
{% include "links.html" %}
{% include "footer.html" %}
</div>
</div>
{% include "footer.html" %}
</body>
</html>
64 changes: 32 additions & 32 deletions husky_directory/templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<div class="uw-footer" style="margin-top:10px;">
<a class="footer-wordmark" href="https://www.washington.edu">University of Washington</a>
<a href="https://www.washington.edu/boundless/be-boundless/"><h3 class="be-boundless">Be boundless</h3></a>
<h4>Connect with us:</h4>
<nav aria-label="social networking" role="navigation">
<ul class="footer-social">
<li><a class="facebook" href="https://www.facebook.com/UofWA">Facebook</a></li>
<li><a class="twitter" href="https://twitter.com/UW">Twitter</a></li>
<li><a class="instagram" href="https://instagram.com/uofwa">Instagram</a></li>
<li><a class="tumblr" href="https://uofwa.tumblr.com/">Tumblr</a></li>
<li><a class="youtube" href="https://www.youtube.com/user/uwhuskies">YouTube</a></li>
<li><a class="linkedin" href="https://www.linkedin.com/company/university-of-washington">LinkedIn</a></li>
<li><a class="pinterest" href="https://www.pinterest.com/uofwa/">Pinterest</a></li>
<li><a class="vine" href="https://vine.co/uofwa">Vine</a></li>
<li><a class="google" href="https://plus.google.com/+universityofwashington/posts">Google+</a></li>
</ul>
</nav>
<nav aria-label="footer links" role="navigation">
<ul class="footer-links">
<li><a href="https://www.uw.edu/accessibility">Accessibility</a></li>
<li><a href="https://uw.edu/home/siteinfo/form">Contact Us</a></li>
<li><a href="https://www.washington.edu/jobs">Jobs</a></li>
<li><a href="https://www.washington.edu/safety">Campus Safety</a></li>
<li><a href="https://myuw.washington.edu/">My UW</a></li>
<li><a href="https://www.washington.edu/admin/rules/wac/rulesindex.html">Rules Docket</a></li>
<li><a href="https://www.washington.edu/online/privacy">Privacy</a></li>
<li><a href="https://www.washington.edu/online/terms">Terms</a></li>
</ul></nav>
<p role="contentinfo" id="footer-copyright">
© {{ current_year }} University of Washington | Seattle, WA
</p>
</div>
<div class="uw-footer" style="margin-top:10px;">
<a class="footer-wordmark" href="https://www.washington.edu">University of Washington</a>
<a href="https://www.washington.edu/boundless/be-boundless/"><h3 class="be-boundless">Be boundless</h3></a>
<h4>Connect with us:</h4>
<nav aria-label="social networking" role="navigation">
<ul class="footer-social">
<li><a class="facebook" href="https://www.facebook.com/UofWA">Facebook</a></li>
<li><a class="twitter" href="https://twitter.com/UW">Twitter</a></li>
<li><a class="instagram" href="https://instagram.com/uofwa">Instagram</a></li>
<li><a class="tumblr" href="https://uofwa.tumblr.com/">Tumblr</a></li>
<li><a class="youtube" href="https://www.youtube.com/user/uwhuskies">YouTube</a></li>
<li><a class="linkedin" href="https://www.linkedin.com/company/university-of-washington">LinkedIn</a></li>
<li><a class="pinterest" href="https://www.pinterest.com/uofwa/">Pinterest</a></li>
<li><a class="vine" href="https://vine.co/uofwa">Vine</a></li>
<li><a class="google" href="https://plus.google.com/+universityofwashington/posts">Google+</a></li>
</ul>
</nav>
<nav aria-label="footer links" role="navigation">
<ul class="footer-links">
<li><a href="https://www.uw.edu/accessibility">Accessibility</a></li>
<li><a href="https://uw.edu/home/siteinfo/form">Contact Us</a></li>
<li><a href="https://www.washington.edu/jobs">Jobs</a></li>
<li><a href="https://www.washington.edu/safety">Campus Safety</a></li>
<li><a href="https://myuw.washington.edu/">My UW</a></li>
<li><a href="https://www.washington.edu/admin/rules/wac/rulesindex.html">Rules Docket</a></li>
<li><a href="https://www.washington.edu/online/privacy">Privacy</a></li>
<li><a href="https://www.washington.edu/online/terms">Terms</a></li>
</ul></nav>
<p role="contentinfo" id="footer-copyright">
© {{ current_year }} University of Washington | Seattle, WA
</p>
</div>
1 change: 0 additions & 1 deletion husky_directory/templates/search_options.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ <h3>Search options</h3>
</a>
{% endif %}
</div>
{% include "search_options/search_type.html" %}
</div>
{% set selected_length = 'summary' %}
{% if request_input is not blank %}
Expand Down
41 changes: 0 additions & 41 deletions husky_directory/templates/search_options/search_type.html

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "uw-husky-directory"
version = "2.0.13"
version = "2.1.0"
description = "An updated version of the UW Directory"
authors = ["Thomas Thorogood <[email protected]>"]
license = "MIT"
Expand Down
Loading

0 comments on commit 901a324

Please sign in to comment.