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

#2741 - Ministry Filter Search Programs and Offerings [Location Search] #3819

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sh16011993
Copy link
Collaborator

@sh16011993 sh16011993 commented Oct 23, 2024

As a part of the PR, the following were completed:

  • Added Location Search for the institution programs in the UI. Each of the searches act as an && operation.
  • Updated the api to include the location in the pagination for the search and updated the sql query fetching the result.

Note: Status search is not a part of this PR. Though, I have added the status as a part of the DTOs and interfaces.

Screenshots:

Location Search added:

image

Location Search with Program Search Empty:

image

Both Location and Program Search:

image

@sh16011993 sh16011993 self-assigned this Oct 23, 2024
Copy link

sonarcloud bot commented Oct 23, 2024

@sh16011993 sh16011993 added the Ministry Ministry Features label Oct 23, 2024
Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 22.4% ( 3634 / 16220 )
Methods: 9.98% ( 201 / 2014 )
Lines: 25.79% ( 3160 / 12252 )
Branches: 13.97% ( 273 / 1954 )

Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 58.64% ( 509 / 868 )
Methods: 52.88% ( 55 / 104 )
Lines: 62.27% ( 411 / 660 )
Branches: 41.35% ( 43 / 104 )

Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 83.21% ( 1160 / 1394 )
Methods: 83.94% ( 115 / 137 )
Lines: 84.26% ( 990 / 1175 )
Branches: 67.07% ( 55 / 82 )

@sh16011993 sh16011993 added the SIMS-Api SIMS-Api label Oct 23, 2024
Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 65.92% ( 5571 / 8451 )
Methods: 63.3% ( 683 / 1079 )
Lines: 70.02% ( 4401 / 6285 )
Branches: 44.8% ( 487 / 1087 )

@guru-aot guru-aot self-requested a review October 23, 2024 16:18
);
queryParams.push(`%${paginationOptions.locationNameSearch}%`);
}
if (paginationOptions.status) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@@ -331,6 +331,33 @@ export class EducationProgramService extends RecordDataModelService<EducationPro
});
queryParams.push(`%${paginationOptions.searchCriteria}%`);
}
if (paginationOptions.programNameSearch) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please correct me if i am wrong, the paginationOptions, if searched with only one criteria, paginationOptions.searchCriteria is used else the paginationOptions.programNameSearch and paginationOptions.locationNameSearch is pushed. If that is the case, either paginationOptions.searchCriteria should be pushed or the paginationOptions.programNameSearch and paginationOptions.locationNameSearch.

Copy link
Collaborator

Choose a reason for hiding this comment

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

searchCriteria should not be used for programs.
@sh16011993 what if we change the service models as below to ensure the searchCriteria will not be present.

export interface BasePaginationOptions {
  sortField?: string;
  sortOrder?: FieldSortOrder;
  page: number;
  pageLimit: number;
}

/**
 *  Pagination option.
 */
export interface PaginationOptions extends BasePaginationOptions {
  searchCriteria?: string;
}

export interface ProgramPaginationOptions extends BasePaginationOptions {
  programNameSearch?: string;
  locationNameSearch?: string;
  status?: string;
}

Copy link
Collaborator

@guru-aot guru-aot left a comment

Choose a reason for hiding this comment

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

Looks good, please have a look on the comment

@MaxLength(PAGINATION_SEARCH_MAX_LENGTH)
locationNameSearch?: string;
@IsOptional()
@IsIn([ProgramStatus.Approved, ProgramStatus.Declined, ProgramStatus.Pending])
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe that it is safe to replace the @IsIn by @IsEnum(ProgramStatus).

locationNameSearch?: string;
@IsOptional()
@IsIn([ProgramStatus.Approved, ProgramStatus.Declined, ProgramStatus.Pending])
status?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please keep the naming pattern from the others: statusSearch.

}
if (paginationOptions.status) {
paginatedProgramQuery.andWhere(
"programs.programStatus Ilike :programStatusSearchCriteria",
Copy link
Collaborator

Choose a reason for hiding this comment

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

programStatus does not require Ilike.

@@ -11,6 +11,12 @@ export interface PaginationOptions {
pageLimit: number;
}

export interface ProgramPaginationOptions extends PaginationOptions {
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot Oct 23, 2024

Choose a reason for hiding this comment

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

Comment on lines +99 to +107
if (
paginationOptions.searchCriteria &&
typeof paginationOptions.searchCriteria === "object"
) {
const searchCriteria = paginationOptions.searchCriteria;
for (const searchCriterion in searchCriteria) {
parameters.push(`${searchCriterion}=${searchCriteria[searchCriterion]}`);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion:

if (!paginationOptions.searchCriteria) {
  return parameters.join("&");
}
// Search criteria.
if (typeof paginationOptions.searchCriteria === "string") {
  // Single search criteria.
  parameters.push(
    `${PaginationParams.SearchCriteria}=${paginationOptions.searchCriteria}`,
  );
  return parameters.join("&");
}
// Multiple search criteria.
const searchCriteria = paginationOptions.searchCriteria;
for (const searchCriterion in paginationOptions.searchCriteria) {
  parameters.push(`${searchCriterion}=${searchCriteria[searchCriterion]}`);
}
return parameters.join("&");

@@ -123,7 +123,7 @@ export enum PaginationParams {
* todo: remove sortOrder: DataTableSortOrder when all primevue datatables are removed.
*/
export interface PaginationOptions {
searchCriteria?: string;
searchCriteria?: string | Record<string, string>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please add a comment to this parameter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Was there a reason why the dropdown for statuses was not included in this PR?

Copy link
Collaborator Author

@sh16011993 sh16011993 Oct 23, 2024

Choose a reason for hiding this comment

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

Yes, as discussed in call with you, there was some confusion related to the status search element's position in the UI and therefore I felt like it might be a little too much work in the same PR.

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a comment

Choose a reason for hiding this comment

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

Great work. Please take a look at the comments.

@sh16011993 sh16011993 marked this pull request as draft October 23, 2024 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ministry Ministry Features SIMS-Api SIMS-Api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants