Skip to content

Search fixes#3193

Open
aidan wants to merge 1 commit into
mainfrom
feature/CDD-3270-boost-topic-pages
Open

Search fixes#3193
aidan wants to merge 1 commit into
mainfrom
feature/CDD-3270-boost-topic-pages

Conversation

@aidan
Copy link
Copy Markdown
Contributor

@aidan aidan commented May 14, 2026

Fixes #CDD-<ISSUE_ID>


Type of change

Please select the options that are relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Tech debt item (this is focused solely on addressing any relevant technical debt)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests at the right levels to prove my change is effective
  • I have added screenshots or screen grabs where appropriate
  • I have added docstrings in the correct style (google)

@aidan aidan requested a review from a team as a code owner May 14, 2026 17:52

DEBUG = True

DATABASES = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this feields are exact replica, could you create it as a variable then reuse it

def get(self, request: Request):
search = request.GET.get("search")
limit = int(request.GET.get("limit", 0))
fields = request.GET.get("fields", ["title", "slug"])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my understanding is that fields would be returned as a string. i would recommend not setting the default as a list but rather splitting the .get value before then doing an if check.

atm it seems like we're trying to handle str and list

search = request.GET.get("search")
limit = int(request.GET.get("limit", 0))
fields = request.GET.get("fields", ["title", "slug"])
meta = request.GET.get("meta", ["id"])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

# for i in range(2):
# TopicPageFactory.create(
# path=f"topic-rare-{i}",
# depth=1,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this if not needed

# Given
search = "rare" # All topics have a title, only even ones have rare in it
query = f"search={search}"
expected_results = [t for t in topics if "rare" in t.title]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be best to use Django's __icontains filter here instead of a forloop?

Comment thread bargrap.http Outdated
@@ -0,0 +1,34 @@
POST http://localhost:8000/api/charts/v3
Content-Type: application/json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the purpose of the .http files?

meta = request.GET.get("meta", ["id"])
topic_results = TopicPage.objects.all().search(search)
if not limit or topic_results.count() < limit:
# TODO: go get more
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may not need the extra count() db query for every search. i think you can check if limit is set then do the limit

@aidan aidan force-pushed the feature/CDD-3270-boost-topic-pages branch from 9591546 to f71e309 Compare May 19, 2026 13:52
@aidan aidan force-pushed the feature/CDD-3270-boost-topic-pages branch from f71e309 to ef6d3e2 Compare May 19, 2026 15:53
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
17.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants