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

FTN-58: Search by indicator id #29

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ataylor-bjss
Copy link
Collaborator

Description

Jira ticket: FTN-58

Include a summary of what this pull request is changing and any relevant background context.

Changes

  • A high-level list of changes made in the PR
  • Added a page to show a thing
  • Updated the service to do something new
  • Etc.

Validation

Details of any validation you have performed to show that your changes are behaving as expected. For example, screenshots of how the UI looks with your changes, or output of any tests you did manually to demonstrate things were working as expected.


let searchService: SearchService;
try {
searchService = new SearchService();
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I'm understanding this correctly. This will be a singleton of the SearchService instance on the NextJS server to handle all requests. Rather than create a new instance per request. Is this the intended idea here and does this have any draw backs? Just thinking performance, load or concurrency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure, although I did think that performing the initial set-up of the search client on each call would be a repetition of effort. My thinking was if Node is single-threaded (think it might be) then creating a new instance each time doesn't help as it's just repeated work, & if it's multi-threaded then there's nothing to stop different threads running the same function.

Comment on lines 16 to 23
const getEnvironmentVariable = (name: string): string => {
return (
process.env[name] ??
(() => {
throw new Error(`Missing environment variable ${name}`);
})()
);
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might make more sense in its own file, as I expect we'll want to use it from other places.

Comment on lines 50 to 55
: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
searchByIndicator(indicator: string): Promise<IndicatorSearchResult[]> {
return Promise.resolve(MOCK_DATA);
},
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be cleaner to implement this as a separate implementation of the IndicatorSearch interface.

const apiKey = getEnvironmentVariable('DHSC_AI_SEARCH_API_KEY');

this.searchClient = new SearchClient<Indicator>(
`https://${serviceName}.search.windows.net`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I appreciate this was how I did it in the PoC, but I think we're probably better taking the full URL to the search service as an environment variable (e.g. https://<serviceName>.search.windows.net), as it means we're not baking in knowledge of the AI search URL structure to our code.

@ataylor-bjss ataylor-bjss marked this pull request as draft December 19, 2024 13:45
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

3 participants