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

feat: add price filter/order on ProductDetail, LocationDetail & UserDetail pages #358

Merged
merged 3 commits into from
Feb 20, 2024

Conversation

dq18
Copy link
Collaborator

@dq18 dq18 commented Feb 18, 2024

What

  • With our database of prices growing and huge GDPR import, we need to have different filters to display prices
  • Added price ordering by "last created" descending and "date"
  • Added price filtering for the last 30 days (can be further improved/reworked)
  • Pages concerned: ProductDetail, LocationDetail, UserDetail

Screenshot

image

Fixes bug

  • Added a small fix to ProductList to avoid doing an API call when going from ProductList page to any other

Closes #343

Copy link
Member

@raphodn raphodn left a comment

Choose a reason for hiding this comment

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

cool ! left only wording/cosmetic comments

src/constants.js Outdated Show resolved Hide resolved
src/constants.js Outdated Show resolved Hide resolved
<v-col>
<v-menu>
<template v-slot:activator="{ props }">
<v-btn v-bind="props" size="small" class="mr-2" prepend-icon="mdi-filter-variant" :active="!!priceFilter">{{ $t('BrandDetail.Filter') }}</v-btn>
Copy link
Member

Choose a reason for hiding this comment

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

BrandDetail.Filter : what's the good practice when there are "common" translation keys. should it be duplicated ? or under a 'Common.Filter' ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I forgot to change this! We should have a common translation indeed

Copy link
Member

Choose a reason for hiding this comment

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

The only issue when renaming a translation key, is that all existing translations are lost, no ? So maybe duplicate ? 🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems there is a "Translation Memory" feature:
https://support.crowdin.com/enterprise/common-questions-translators/#can-i-use-project-translation-memory-where-do-i-find-it
So if I rename the key, Crowdin should add all translations from memory to the renamed key.

src/views/LocationDetail.vue Outdated Show resolved Hide resolved
src/constants.js Outdated
@@ -10,11 +10,18 @@ export default {
PRODUCT_FILTER_LIST: [
{ key: 'hide_price_count_gte_1', value: 'Hide products with prices' },
],
PRICE_FILTER_LIST: [
{ key: 'show_last_month', value: 'Show Prices from Last 30 Days' },
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{ key: 'show_last_month', value: 'Show Prices from Last 30 Days' },
{ key: 'only_last_30d', value: 'Only prices for the last 30 days' },

Copy link
Member

Choose a reason for hiding this comment

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

btw these order / filter labels are not translated (seperate PR)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I wanted to discuss on this first since it would mean adding translation in constant.js

Copy link
Member

Choose a reason for hiding this comment

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

Or doing something similar as routes.js ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will create another PR

src/views/LocationDetail.vue Outdated Show resolved Hide resolved
if (this.priceFilter === 'show_last_month') {
let oneMonthAgo = new Date()
oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1)
defaultParams['date__gte'] = oneMonthAgo.toISOString().split('T')[0]
Copy link
Member

Choose a reason for hiding this comment

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

in the code elsewhere we used toISOString().substring(0, 10). better ?

Copy link
Collaborator Author

@dq18 dq18 Feb 19, 2024

Choose a reason for hiding this comment

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

Tested on a 1000000 loop
split: 318.093994140625 ms
substring: 3.641845703125 ms
split: 264.632080078125 ms
substring: 0.674072265625 ms

substring is indeed faster (300 nano second compared to 1ns). But both are still super fast. I guess it is down to readability. Both are fine by me, though we should try to stay uniform in the code (unless we start looping like crazy)

Copy link
Member

Choose a reason for hiding this comment

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

Wasn't thinking about speed. Just uniformity 👍

@dq18 dq18 merged commit 1d5163d into master Feb 20, 2024
2 checks passed
@dq18 dq18 deleted the price-filter branch February 20, 2024 09:27
@raphodn raphodn changed the title feat: add price filter feat: add price filter/order on ProductDetail, LocationDetail & UserDetail pages Feb 20, 2024
raphodn added a commit that referenced this pull request Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Price list display in shop and product pages by descending date order
2 participants