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

[#11302] Increase search result limit with message prompt when limit is reached #11324

Merged
merged 21 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
85a22cf
Increase search result limit with message prompt when limit is reached
tjtanjin Aug 2, 2021
3e0cb03
Fix linting errors
tjtanjin Aug 2, 2021
cddadb2
Update snapshots to match UI changes
tjtanjin Aug 3, 2021
050add9
Fix merge conflicts
tjtanjin Aug 12, 2021
00a8460
Merge branch 'master' into increase-search-results-limit
daongochieu2810 Aug 22, 2021
9dc2dc6
Merge branch 'master' into increase-search-results-limit
tjtanjin Aug 23, 2021
bc3b37b
Reduce if-statement nesting
tjtanjin Aug 29, 2021
992bb40
Merge branch 'increase-search-results-limit' of https://github.com/tj…
tjtanjin Aug 29, 2021
955f5e2
Fix linting issues
tjtanjin Aug 29, 2021
46374dd
Fix typo in message prompt
tjtanjin Sep 6, 2021
e13eb92
Merge branch 'master' into increase-search-results-limit
daongochieu2810 Sep 7, 2021
f1be81a
Fix merge conflict
tjtanjin Oct 26, 2021
f0efec1
Shift query size value to backend and show individual prompts for ins…
tjtanjin Oct 26, 2021
b4a580e
Merge branch 'increase-search-results-limit' of https://github.com/tj…
tjtanjin Oct 26, 2021
a2a6334
Fix linting errors
tjtanjin Oct 26, 2021
8649de2
Merge branch 'master' into increase-search-results-limit
tjtanjin Oct 27, 2021
b2c74b0
Rename query size limit constant
tjtanjin Oct 31, 2021
d58fcd4
Clean up code to reduce repetition
tjtanjin Oct 31, 2021
d2c03fe
Merge branch 'increase-search-results-limit' of https://github.com/tj…
tjtanjin Oct 31, 2021
fe57332
Update failing snapshots for admin search page
tjtanjin Oct 31, 2021
469e83b
Clean up code for search limit message
tjtanjin Nov 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/teammates/storage/search/SearchManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class SearchManager<T extends EntityAttributes<?>> {
"Failed to reset collections. Root cause: %s ";

private static final int START_INDEX = 0;
private static final int NUM_OF_RESULTS = 20;
private static final int NUM_OF_RESULTS = 50;

private final HttpSolrClient client;
private final boolean isResetAllowed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exports[`AdminSearchPageComponent should snap with a search key 1`] = `
emailGenerationService={[Function EmailGenerationService]}
instructors={[Function Array]}
loadingBarService={[Function LoadingBarService]}
maxResultsToShow={[Function Number]}
searchQuery={[Function String]}
searchService={[Function SearchService]}
simpleModalService={[Function SimpleModalService]}
Expand Down Expand Up @@ -54,6 +55,7 @@ exports[`AdminSearchPageComponent should snap with an expanded instructor table
emailGenerationService={[Function EmailGenerationService]}
instructors={[Function Array]}
loadingBarService={[Function LoadingBarService]}
maxResultsToShow={[Function Number]}
searchQuery=""
searchService={[Function SearchService]}
simpleModalService={[Function SimpleModalService]}
Expand Down Expand Up @@ -260,6 +262,7 @@ exports[`AdminSearchPageComponent should snap with an expanded student table 1`]
emailGenerationService={[Function EmailGenerationService]}
instructors={[Function Array]}
loadingBarService={[Function LoadingBarService]}
maxResultsToShow={[Function Number]}
searchQuery=""
searchService={[Function SearchService]}
simpleModalService={[Function SimpleModalService]}
Expand Down Expand Up @@ -567,6 +570,7 @@ exports[`AdminSearchPageComponent should snap with default fields 1`] = `
emailGenerationService={[Function EmailGenerationService]}
instructors={[Function Array]}
loadingBarService={[Function LoadingBarService]}
maxResultsToShow={[Function Number]}
searchQuery=""
searchService={[Function SearchService]}
simpleModalService={[Function SimpleModalService]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class AdminSearchPageComponent {
searchQuery: string = '';
instructors: InstructorAccountSearchResult[] = [];
students: StudentAccountSearchResult[] = [];
maxResultsToShow: number = 50;
wkurniawan07 marked this conversation as resolved.
Show resolved Hide resolved

constructor(
private statusMessageService: StatusMessageService,
Expand All @@ -59,11 +60,16 @@ export class AdminSearchPageComponent {
this.statusMessageService.showWarningToast('No results found.');
this.instructors = [];
this.students = [];
} else {
this.instructors = resp.instructors;
this.students = resp.students;
this.hideAllInstructorsLinks();
this.hideAllStudentsLinks();
return;
}

this.instructors = resp.instructors;
this.students = resp.students;
this.hideAllInstructorsLinks();
this.hideAllStudentsLinks();
if (this.instructors.length + this.students.length >= this.maxResultsToShow) {
wkurniawan07 marked this conversation as resolved.
Show resolved Hide resolved
this.statusMessageService.showWarningToast(`${this.maxResultsToShow} results have been shown on this page
but there may be more results not shown. Consider searching with more specific terms.`);
}
Copy link
Member

Choose a reason for hiding this comment

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

Here's how I'm going to refactor this part:

const limit: number = ApiConst.SEARCH_QUERY_SIZE_LIMIT;
const limitsReached: string[] = [];
if (this.students.length >= limit) {
  limitsReached.push(`${limit} student results`);
}
if (this.instructors.length >= limit) {
  limitsReached.push(`${limit} instructor results`);
}
if (limitsReached.length) {
  this.statusMessageService.showWarningToast(`${limitsReached.join(' and ')} have been shown on this page
      but there may be more results not shown. Consider searching with more specific terms.`);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the code according to your suggestion, thank you!

}, (resp: ErrorMessageOutput) => {
this.instructors = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`InstructorSearchPageComponent should snap with a search key 1`] = `
<tm-instructor-search-page
courseService={[Function CourseService]}
isSearching="false"
maxResultsToShow={[Function Number]}
searchParams={[Function Object]}
searchService={[Function SearchService]}
searchWarningDisplayed="false"
Expand Down Expand Up @@ -76,6 +77,7 @@ exports[`InstructorSearchPageComponent should snap with a student table 1`] = `
<tm-instructor-search-page
courseService={[Function CourseService]}
isSearching="false"
maxResultsToShow={[Function Number]}
searchParams={[Function Object]}
searchService={[Function SearchService]}
searchWarningDisplayed="false"
Expand Down Expand Up @@ -606,6 +608,7 @@ exports[`InstructorSearchPageComponent should snap with default fields 1`] = `
<tm-instructor-search-page
courseService={[Function CourseService]}
isSearching="false"
maxResultsToShow={[Function Number]}
searchParams={[Function Object]}
searchService={[Function SearchService]}
searchWarningDisplayed="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class InstructorSearchPageComponent implements OnInit {
};
studentsListRowTables: SearchStudentsListRowTable[] = [];
isSearching: boolean = false;
maxResultsToShow: number = 50;
searchWarningDisplayed: boolean = !!environment.searchWarningDisplayed;

constructor(
Expand Down Expand Up @@ -66,6 +67,10 @@ export class InstructorSearchPageComponent implements OnInit {

if (hasStudents) {
this.studentsListRowTables = searchStudentsTable;
if (searchStudentsTable.length >= this.maxResultsToShow) {
this.statusMessageService.showWarningToast(`${this.maxResultsToShow} results have been shown on this page
but there may be more results not shown. Consider searching with more specific terms.`);
}
} else {
this.studentsListRowTables = [];
}
Expand Down