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

Allow for the GET /listings request param to specify how the results should be ordered #548

Merged
merged 32 commits into from
Sep 10, 2021

Conversation

anders-schneider
Copy link

@anders-schneider anders-schneider commented Sep 9, 2021

Issue

Description

This change adds an orderBy field to the ListingsQueryParams so that requests to GET /listings can indicate how the listings should be sorted. Currently there are only two options: order by most recently updated or by "application dates".

("application dates" is the pre-existing behavior: order by soonest applicationDueDate, and then by earliest applicationOpenDate. Since "application dates" was the pre-existing behavior, this change preserves that as the default ordering if no orderBy param is specified.)

A few other smaller notes:

  • The pre-existing behavior also sorted units within a listing by max_occupancy. This change keeps that behavior, by applying the max_occupancy sorting on the full query. (There's no need to apply that on the innerFilteredQuery because it doesn't return individual units.)
  • This change updates sites/public so that the full listings page requests listings with the orderBy=mostRecentlyUpdated parameter.
  • This change updates some of the seed listings to have "more interesting" application dates.

Type of change

  • 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)
  • Prototype/POC (not to merge)
  • This change is a refactor/address technical debt
  • This change requires a documentation update
  • This change requires a SQL Script

How Can This Be Tested/Reviewed?

  • Desktop View
  • Mobile View
  • $ cd backend/core && yarn test
  • $ cd backend/core && yarn test:e2e:local

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have reviewed the changes in a desktop view
  • I have reviewed the changes in a mobile view
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have assigned reviewers
  • I have updated the changelog to include a description of my changes
  • I have run yarn generate:client if I made backend changes

@anders-schneider anders-schneider marked this pull request as ready for review September 10, 2021 17:35
Copy link

@avaleske avaleske left a comment

Choose a reason for hiding this comment

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

LGTM

@anders-schneider anders-schneider merged commit 4d013ea into main Sep 10, 2021
@anders-schneider anders-schneider deleted the 193/sort-listings-by-param branch September 10, 2021 21:08
anders-schneider added a commit that referenced this pull request Sep 10, 2021
…s should be ordered (#548)

* Add field to ListingsQueryParam (still need to add tests)

* Fix code style issues with Prettier

* Update frontend to request listings sorted by mostRecentlyUpdated

* Fix code style issues with Prettier

* Add tests

* Fix code style issues with Prettier

* Add an error test and a comment

* Small test change

* Fix code style issues with Prettier

* Test change

* Refactor getOrderByCondition

* Update comment

* Fix code style issues with Prettier

* Update enum value name

* Fix code style issues with Prettier

* Small updates

* Update changelog

* Update changelog

* Whoops one more change to the changelog

* Fix code style issues with Prettier

* Update test names

* Fix code style issues with Prettier

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>
seanmalbert pushed a commit that referenced this pull request Sep 14, 2021
* Sort listings (returned by `GET /listings`) by `updatedAt` (#542)

* Add a simple ordering by updated_at

* Change the helper function name

* Add comments, update changelog

* Fix code style issues with Prettier

* Add a test for interaction of pagination and sorting

* Fix code style issues with Prettier

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>

* Fix the ordering of unit summaries returned by `GET /listings` (#547)

* Order full listings query by unit summary number of bedrooms

* Fix code style issues with Prettier

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>

* Allow for the `GET /listings` request param to specify how the results should be ordered (#548)

* Add field to ListingsQueryParam (still need to add tests)

* Fix code style issues with Prettier

* Update frontend to request listings sorted by mostRecentlyUpdated

* Fix code style issues with Prettier

* Add tests

* Fix code style issues with Prettier

* Add an error test and a comment

* Small test change

* Fix code style issues with Prettier

* Test change

* Refactor getOrderByCondition

* Update comment

* Fix code style issues with Prettier

* Update enum value name

* Fix code style issues with Prettier

* Small updates

* Update changelog

* Update changelog

* Whoops one more change to the changelog

* Fix code style issues with Prettier

* Update test names

* Fix code style issues with Prettier

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>

* Revert changes to sites/public

* Revert a couple Detroit-specific changes

* Fix up a comment

* Small formatting changes

* Fix a lint error

* Fix another small lint error

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>
seanmalbert pushed a commit that referenced this pull request Jun 23, 2022
…s should be ordered (#548)

* Add field to ListingsQueryParam (still need to add tests)

* Fix code style issues with Prettier

* Update frontend to request listings sorted by mostRecentlyUpdated

* Fix code style issues with Prettier

* Add tests

* Fix code style issues with Prettier

* Add an error test and a comment

* Small test change

* Fix code style issues with Prettier

* Test change

* Refactor getOrderByCondition

* Update comment

* Fix code style issues with Prettier

* Update enum value name

* Fix code style issues with Prettier

* Small updates

* Update changelog

* Update changelog

* Whoops one more change to the changelog

* Fix code style issues with Prettier

* Update test names

* Fix code style issues with Prettier

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>
seanmalbert pushed a commit that referenced this pull request Jun 23, 2022
* Sort listings (returned by `GET /listings`) by `updatedAt` (#542)

* Add a simple ordering by updated_at

* Change the helper function name

* Add comments, update changelog

* Fix code style issues with Prettier

* Add a test for interaction of pagination and sorting

* Fix code style issues with Prettier

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>

* Fix the ordering of unit summaries returned by `GET /listings` (#547)

* Order full listings query by unit summary number of bedrooms

* Fix code style issues with Prettier

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>

* Allow for the `GET /listings` request param to specify how the results should be ordered (#548)

* Add field to ListingsQueryParam (still need to add tests)

* Fix code style issues with Prettier

* Update frontend to request listings sorted by mostRecentlyUpdated

* Fix code style issues with Prettier

* Add tests

* Fix code style issues with Prettier

* Add an error test and a comment

* Small test change

* Fix code style issues with Prettier

* Test change

* Refactor getOrderByCondition

* Update comment

* Fix code style issues with Prettier

* Update enum value name

* Fix code style issues with Prettier

* Small updates

* Update changelog

* Update changelog

* Whoops one more change to the changelog

* Fix code style issues with Prettier

* Update test names

* Fix code style issues with Prettier

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>

* Revert changes to sites/public

* Revert a couple Detroit-specific changes

* Fix up a comment

* Small formatting changes

* Fix a lint error

* Fix another small lint error

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>
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