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

Fix POST handling of localized PNI products #7555

Merged
merged 7 commits into from
Oct 5, 2021
Merged

Fix POST handling of localized PNI products #7555

merged 7 commits into from
Oct 5, 2021

Conversation

Pomax
Copy link
Contributor

@Pomax Pomax commented Oct 4, 2021

Closes #7502

This gives PNI products an .original_product accessor for finding the English version of a product (based on product slug), with a refactor of the code that fetches the DEFAULT_LOCALE and DEFAULT_LOCALE_ID, which are required to make sure that we can find the original English version of products. We didn't have "one place to get them" so there were a bunch of files that all reinvented the wheel, all of those now use the same function to get default locale information.

This also update some of the @property functions for ProductPage so that total votes and creepiness are derived from the original product, and not a localized alias/published version of that product, both of which are used in the average-creepiness calculation for ranking items on the homepage/category pages.

Finally, it makes sure to always template the creepiness value into the product page in an unlocalized fashion, so that the JS that hooks into it doesn't get confused by numbers that use commas instead of period for decimal points.

Bad case STR:

This will show a different ordering, where on the English page, you should see Threema, Signal, FaceTime, and Jitsi Meet as top four, whereas on the French page, there are very different elements at the top.

  • DOM inspect the pages, and you should see a list of <figure...> elements that have data-creepiness that starts at ~13 and ends at ~82 for the English page
  • on the French page, you'll see these values start at 0,10660980810234541 (or similar), with comma instead of period, and end at 98,6 (or similar), again with comma.

Fixed case STR:

  • docker-compose down
  • check out this branch
  • docker-compose up
  • reload the two category pages
  • both should show identical ordering
  • inspecting the DOM should show identical data-creepiness values

@mofodevops mofodevops temporarily deployed to foundation-s-fix-pni-vo-2zjujb October 4, 2021 21:10 Inactive
@MozillaFoundation MozillaFoundation deleted a comment from github-actions bot Oct 4, 2021
@Pomax Pomax temporarily deployed to foundation-s-fix-pni-vo-2zjujb October 4, 2021 22:43 Inactive
@Pomax Pomax temporarily deployed to foundation-s-fix-pni-vo-2zjujb October 4, 2021 22:48 Inactive
@Pomax Pomax changed the title [WIP] fix POST handling of localized PNI products Fix POST handling of localized PNI products Oct 4, 2021
def original_product(self):
return get_original_by_slug(ProductPage, self.slug)

def get_or_create_votes(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this just got moved up, so that it's next to the other vote-related function/properties

@Pomax Pomax temporarily deployed to foundation-s-fix-pni-vo-2zjujb October 5, 2021 00:03 Inactive
@@ -375,33 +375,35 @@ def test_get_or_create_votes(self):
class WagtailBuyersGuideVoteTest(APITestCase, BuyersGuideTestMixin):

def test_successful_vote(self):
product_page = self.product_page
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is basically a noop refactor, I thought I would be able to add tests in this PR, but it turns out that's much more work, so I filed #7559 to tackle that monster.

@MozillaFoundation MozillaFoundation deleted a comment from github-actions bot Oct 5, 2021
@MozillaFoundation MozillaFoundation deleted a comment from github-actions bot Oct 5, 2021
@MozillaFoundation MozillaFoundation deleted a comment from github-actions bot Oct 5, 2021
@Pomax Pomax temporarily deployed to foundation-s-fix-pni-vo-2zjujb October 5, 2021 15:11 Inactive
Copy link
Contributor

@TheoChevalier TheoChevalier left a comment

Choose a reason for hiding this comment

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

Did some testing with the staging DB, couldn’t spot any issue

@Pomax Pomax temporarily deployed to foundation-s-fix-pni-vo-2zjujb October 5, 2021 17:47 Inactive
@MozillaFoundation MozillaFoundation deleted a comment from github-actions bot Oct 5, 2021
@MozillaFoundation MozillaFoundation deleted a comment from github-actions bot Oct 5, 2021
@Pomax Pomax removed the request for review from danielfmiranda October 5, 2021 18:48
@Pomax Pomax merged commit 7a9c8ec into main Oct 5, 2021
@Pomax Pomax deleted the fix-pni-voting branch October 5, 2021 18:49
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.

PNI creepy ratings on non-English pages is in the wrong order
3 participants