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

Enable Sorting on Search By Created and Updated At #140

Conversation

Rshep3087
Copy link
Contributor

@Rshep3087 Rshep3087 commented Jul 20, 2024

What type of PR is this?

  • feature

What this PR does / why we need it:

This enables the user to order their items on the search page by name, created at and updated at

Showing the new option:
image

Ordered by updated at:
image

Which issue(s) this PR fixes:

Fixes #113

Special notes for your reviewer:

I needed to update the useRouteQuery func to grab the first.value in the get func, otherwise it would be undefined for strings.

This MR only enables it to be sortable. Searching last updated doesn't really make sense imo. Updated timestamp already show up on the detail of the item also.

Testing

Sort by updated at - make an update to the end of the list items - check they are pushed to the front of the listed items.

Summary by CodeRabbit

  • New Features
    • Introduced sorting functionality in the items page, allowing users to sort items by criteria such as "Name", "Created At", and "Updated At" via a dropdown menu.
    • Implemented dynamic updates to the displayed items based on the selected sorting method.
  • Bug Fixes
    • Improved the method of retrieving query parameters to ensure consistent behavior across components.

- Required updating query value to use first.value
  to set the value of the initial sort

- Ordering starts with name but can be changed to
  createdAt or updatedAt by the user
Copy link
Contributor

coderabbitai bot commented Jul 20, 2024

Walkthrough

Walkthrough

The recent changes enhance user interactivity in the application by introducing a sorting feature for items based on various criteria. Users can now dynamically select sorting preferences via a dropdown, which integrates with route query parameters to maintain state. Furthermore, modifications to the underlying logic for fetching route queries streamline data handling, potentially improving performance and usability.

Changes

File Path Change Summary
frontend/composables/use-route-params.ts Modified useRouteQuery function to obtain query values using first.value, enhancing data retrieval methods without altering the function signature.
frontend/pages/items.vue Introduced sorting functionality with a new reactive variable orderBy, which is derived from route query parameters. Added a dropdown for sorting options and linked it to component data fetching.

Assessment against linked issues

Objective Addressed Explanation
Enable sorting by 'last updated' and missing info fields (Issue #113)
Implement a checkbox for 'organized' status to filter items (Issue #113) Checkbox feature for organization not included.
Allow for sorting based on various criteria, including 'Created At' (Issue #113)

Poem

In the realm of code where items lay,
A sorting feature brightens the day.
With dropdowns to choose, and queries anew,
Users rejoice as their wishes come true!
🎉 Sorting made simple, the data in flow,
Enhancing the app, watch its brilliance grow!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2d1016d and 84f163b.

Files selected for processing (2)
  • frontend/composables/use-route-params.ts (1 hunks)
  • frontend/pages/items.vue (7 hunks)
Additional comments not posted (5)
frontend/composables/use-route-params.ts (1)

35-35: Verify the correctness of the query value retrieval.

The change to use first.value instead of route.query[q] ensures the query value is retrieved as a string. This modification looks correct, but verify that first.value is properly initialized and used consistently throughout the codebase.

Verification successful

Sir, we need to re-evaluate our approach to ensure the accurate retrieval and initialization of first.value. Allow me to execute a refined search command.


Verification successful: The query value retrieval and initialization are correct.

The first constant is properly initialized using computed<string>, ensuring the query value is consistently converted to a string. The modification to use first.value instead of route.query[q] directly is correct.

  • frontend/composables/use-route-params.ts:
    • Initialization of first: const first = computed<string>(() => { ... })
    • Correct handling of query values as strings.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and initialization of `first.value` in the codebase.

# Test: Search for the initialization and usage of `first.value`. Expect: Correct initialization and consistent usage.
rg --type javascript -A 5 $'const first = computed<string>'

Length of output: 95


Script:

#!/bin/bash
# Description: Verify the usage and initialization of `first.value` in the codebase.

# Test: Search for the initialization and usage of `first.value`. Expect: Correct initialization and consistent usage.
rg 'const first = computed<string>' -t js -t ts -A 5

Length of output: 480

frontend/pages/items.vue (4)

43-43: Initialization of orderBy looks good.

The orderBy variable is correctly initialized using the useRouteQuery function to retrieve the sorting preference from the route query parameters.


173-177: Watch function for orderBy is well-implemented.

The watch function correctly triggers a search operation whenever the sorting criteria changes, ensuring the displayed items are updated accordingly.


211-211: Inclusion of orderBy in the advanced watch function is appropriate.

The orderBy variable is correctly included in the data sent to the server during fetch operations, ensuring the backend handles the sorting logic based on the user's preference.


387-394: Dropdown UI element for sorting options is well-designed.

The new dropdown UI element allows users to select their preferred sorting method from options such as "Name", "Created At", and "Updated At", enhancing the interactivity and usability of the component.

@tankerkiller125 tankerkiller125 merged commit c9f31ef into sysadminsmedia:main Jul 21, 2024
2 checks passed
@Rshep3087 Rshep3087 deleted the rshep3087/order-items-by-updated-at branch July 21, 2024 13:49
@katosdev
Copy link
Contributor

On a roll! Fantastic contribution, thanks so much @Rshep3087 ! ❤️

truecharts-admin referenced this pull request in truecharts/public Jul 27, 2024
… v0.13.0@90328a8 by renovate (#24463)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
|
[ghcr.io/sysadminsmedia/homebox](https://togithub.com/sysadminsmedia/homebox)
| minor | `0.12.1` -> `0.13.0` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>sysadminsmedia/homebox
(ghcr.io/sysadminsmedia/homebox)</summary>

###
[`v0.13.0`](https://togithub.com/sysadminsmedia/homebox/releases/tag/v0.13.0)

[Compare
Source](https://togithub.com/sysadminsmedia/homebox/compare/v0.12.1...v0.13.0)

#### What's Changed

- docs: update get-started.md by
[@&#8203;eltociear](https://togithub.com/eltociear) in
[https://github.com/sysadminsmedia/homebox/pull/106](https://togithub.com/sysadminsmedia/homebox/pull/106)
- Update location pricing to include quantity in calculation by
[@&#8203;katosdev](https://togithub.com/katosdev) in
[https://github.com/sysadminsmedia/homebox/pull/123](https://togithub.com/sysadminsmedia/homebox/pull/123)
- Create a Github Workflow to keep currencies in sync from API by
[@&#8203;katosdev](https://togithub.com/katosdev) in
[https://github.com/sysadminsmedia/homebox/pull/129](https://togithub.com/sysadminsmedia/homebox/pull/129)
- Update update_currencies.py to fix error handling by
[@&#8203;katosdev](https://togithub.com/katosdev) in
[https://github.com/sysadminsmedia/homebox/pull/130](https://togithub.com/sysadminsmedia/homebox/pull/130)
- Skip commit attempt if currencies already synced with API by
[@&#8203;katosdev](https://togithub.com/katosdev) in
[https://github.com/sysadminsmedia/homebox/pull/131](https://togithub.com/sysadminsmedia/homebox/pull/131)
- Force rebase on Update-currencies action by
[@&#8203;katosdev](https://togithub.com/katosdev) in
[https://github.com/sysadminsmedia/homebox/pull/132](https://togithub.com/sysadminsmedia/homebox/pull/132)
- Update currencies by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[https://github.com/sysadminsmedia/homebox/pull/133](https://togithub.com/sysadminsmedia/homebox/pull/133)
- Add nmprc to automatically hoist dependencies by
[@&#8203;PatrickDaG](https://togithub.com/PatrickDaG) in
[https://github.com/sysadminsmedia/homebox/pull/136](https://togithub.com/sysadminsmedia/homebox/pull/136)
- Add URL column to CSV export for items by
[@&#8203;Rshep3087](https://togithub.com/Rshep3087) in
[https://github.com/sysadminsmedia/homebox/pull/141](https://togithub.com/sysadminsmedia/homebox/pull/141)
- Enable Sorting on Search By Created and Updated At by
[@&#8203;Rshep3087](https://togithub.com/Rshep3087) in
[https://github.com/sysadminsmedia/homebox/pull/140](https://togithub.com/sysadminsmedia/homebox/pull/140)
- Update currencies by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[https://github.com/sysadminsmedia/homebox/pull/143](https://togithub.com/sysadminsmedia/homebox/pull/143)
- Splitting dependencies into separate docker layers (better caching) by
[@&#8203;tankerkiller125](https://togithub.com/tankerkiller125) in
[https://github.com/sysadminsmedia/homebox/pull/142](https://togithub.com/sysadminsmedia/homebox/pull/142)
- chore: update openapi documentation by
[@&#8203;tankerkiller125](https://togithub.com/tankerkiller125) in
[https://github.com/sysadminsmedia/homebox/pull/148](https://togithub.com/sysadminsmedia/homebox/pull/148)

#### New Contributors

- [@&#8203;eltociear](https://togithub.com/eltociear) made their first
contribution in
[https://github.com/sysadminsmedia/homebox/pull/106](https://togithub.com/sysadminsmedia/homebox/pull/106)
- [@&#8203;github-actions](https://togithub.com/github-actions) made
their first contribution in
[https://github.com/sysadminsmedia/homebox/pull/133](https://togithub.com/sysadminsmedia/homebox/pull/133)
- [@&#8203;PatrickDaG](https://togithub.com/PatrickDaG) made their first
contribution in
[https://github.com/sysadminsmedia/homebox/pull/136](https://togithub.com/sysadminsmedia/homebox/pull/136)
- [@&#8203;Rshep3087](https://togithub.com/Rshep3087) made their first
contribution in
[https://github.com/sysadminsmedia/homebox/pull/141](https://togithub.com/sysadminsmedia/homebox/pull/141)

**Full Changelog**:
sysadminsmedia/homebox@v0.12.1...v0.13.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44LjMiLCJ1cGRhdGVkSW5WZXIiOiIzOC44LjMiLCJ0YXJnZXRCcmFuY2giOiJtYXN0ZXIiLCJsYWJlbHMiOlsiYXV0b21lcmdlIiwidXBkYXRlL2RvY2tlci9nZW5lcmFsL25vbi1tYWpvciJdfQ==-->
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.

Feature Request: Missing Info / Last Updated Search & "Organized" Checkbox
3 participants