Skip to content

Added searchCampRequest and searchCampResponse for searching camps#11

Open
anubratabhowmick wants to merge 1 commit intodevelopmentfrom
campSearch
Open

Added searchCampRequest and searchCampResponse for searching camps#11
anubratabhowmick wants to merge 1 commit intodevelopmentfrom
campSearch

Conversation

@anubratabhowmick
Copy link
Copy Markdown
Collaborator

No description provided.

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #11 into development will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             development    #11   +/-   ##
============================================
  Coverage            100%   100%           
  Complexity            26     26           
============================================
  Files                  5      5           
  Lines                 92     92           
  Branches               3      3           
============================================
  Hits                  92     92

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 061850a...d5e6c92. Read the comment docs.


Integer pageSize;

String sortBy;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why is this required in the response?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Shouldn't we show on which basis the page is sorted?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

the client will be passing the sortBy field to you. How does it add any value to return the same thing back in the response?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Point


Integer pageNo;

Integer pageSize;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why is this required in the response?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Won't we have to show the page number?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

but this is pageSize, which is being passed by the client to begin with.


Long actualNoOfDonors;

Integer pageNo;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Instead of returning the page number, is there a way we can return the total number of results instead? That way calculating page number will be easy as we can just do totalResults/pageSize. This will also allows us to change the pageSize and still use the same request.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We can return the number of rows fetched from the database and return that as totalNoOfResponse to get how many camps are present, which can be used to calculate and modify pageSize. Does that work?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What do you mean by 'the number of rows fetched from the database'? The database query will only return rows equal to the size of the page being passed since we want a paginated query, and if you return that number, our calculation will always show that only a single page exists, which might not be correct.
However, if you mean this is the total number of rows which match the given query then, yes, that works.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes yes... Total no. of rows 🥇


private String actualNoOfDonors;

Integer pageNo;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

add validation to ensure this is greater than 0.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

forgot to mention, you can do this very cleanly by just using jsrValidations. Add hibernate-validator as a dependency.


Integer pageNo;

Integer pageSize;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

add validation to ensure this is greater than 0


Integer pageSize;

String sortBy;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can we use an enum with all the fields of CampModel and accept that here instead of String?


private String partnerId;

private Date dateOfCamp;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

how are you going to handle range queries?


@Value
@Builder
public class SearchCampRequest {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Are we going to handle AND and OR searches? For example,

  1. Search for all camps where partnerId = A OR partnerId = B
  2. Search for all camps where partnerId = A AND dateOfCamp between(date1, date2)

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.

4 participants