Format plural for number of installs

Created on 27 September 2024, 3 months ago

Problem/Motivation

When there is only 1 install of a module, it still says "1 installs" but proper grammar is "1 install"

Proposed resolution

We can use the Drupal.formatPlural JS method to format this better.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States chrisfromredfin Portland, Maine

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @chrisfromredfin
  • Merge request !588#3477314: Format plural for number of installs → (Merged) created by omkar-pd
  • Pipeline finished with Failed
    3 months ago
    Total: 449s
    #294524
  • 🇺🇸United States phenaproxima Massachusetts

    Needs to be rebased against 2.0.x...

  • Pipeline finished with Success
    3 months ago
    #297100
  • 🇺🇸United States phenaproxima Massachusetts

    One question, otherwise I don't see any obvious problem with this.

  • 🇮🇳India omkar-pd

    Required changes done.

  • Pipeline finished with Failed
    3 months ago
    #297129
  • 🇺🇸United States phenaproxima Massachusetts

    Not quite done...

  • Pipeline finished with Success
    3 months ago
    #297139
  • Pipeline finished with Running
    3 months ago
    #297148
  • 🇺🇸United States phenaproxima Massachusetts

    That looks correct to me - I think we'd want to use project.project_usage_total since formatPlural() is treating it as a number, not a string. RTBC assuming tests pass!

  • Pipeline finished with Success
    3 months ago
    #297151
  • 🇮🇪Ireland lostcarpark

    The code change looks good, but should this have test coverage? Pretty sure if this was in core a test would be required.

  • 🇺🇸United States chrisfromredfin Portland, Maine
  • 🇺🇸United States chrisfromredfin Portland, Maine
  • Pipeline finished with Success
    about 1 month ago
    Total: 505s
    #341207
  • Pipeline finished with Success
    about 1 month ago
    Total: 422s
    #341219
  • Pipeline finished with Success
    about 1 month ago
    Total: 575s
    #341231
  • Pipeline finished with Success
    about 1 month ago
    Total: 345s
    #341245
  • 🇮🇪Ireland lostcarpark

    Updated fixture to make the total installs of the Grapefruit module 1. Required some minor adjustments to existing tests.

    Added testInstallCountPluralFormatting test to search for Grapefruit and check install count text is "1 install". Also checks for Octopus module ("235 installs").

    I used an xpath query to check that against the complete text on the element, as just checking for "1 install" in the output would also pass for "1 installs".

  • 🇺🇸United States chrisfromredfin Portland, Maine

    Test looks mostly good, but I'd rather it only test that the install formatting is good. It feels like it's also inadvertently testing search capabilities. Can we just make the first two results on page one our two test cases?

  • Pipeline finished with Canceled
    about 1 month ago
    Total: 295s
    #342726
  • Pipeline finished with Success
    about 1 month ago
    Total: 406s
    #342728
  • 🇮🇪Ireland lostcarpark

    I realised that with a very small change to the fixture, we could get the module with 1 install onto the front page, simplifying the new test considerably.

    Unfortunately, I ended up having to make a lot of small fixes to other tests. I think it's worth it, though.

    I considered adding a "0 installs" test case, but I realised that when a module has no installs, there is no install count label at all. It might be worth adding a new test for that, but it seems out of scope for this issue. I will look at opening a follow on issue.

    All tests are now passing, so moving to Needs Review.

  • Pipeline finished with Success
    24 days ago
    Total: 527s
    #352338
  • Status changed to Needs review 24 days ago
  • 🇮🇪Ireland lostcarpark

    Rebased for latest changes. Tests passing. Manually tested, and verified appearing correctly for modules with a single install.

  • 🇮🇳India narendraR Jaipur, India

    Looks good to me. Tested manually and it is working as expected.
    Should we also consider fixing 1 sites report using this module on modal in scope of this issue?

  • 🇮🇳India narendraR Jaipur, India

    Moving it back to NW for #20, unless someone thinks otherwise.

  • First commit to issue fork.
  • Pipeline finished with Failed
    18 days ago
    Total: 584s
    #358547
  • Pipeline finished with Failed
    18 days ago
    Total: 410s
    #358559
  • Pipeline finished with Canceled
    18 days ago
    Total: 225s
    #358574
  • Pipeline finished with Success
    18 days ago
    Total: 409s
    #358578
  • 🇮🇳India shalini_jha

    I have reviewed the feedback mentioned in #20 and have tried to update the implementation accordingly, following the formatPlural same as for install case. Since the numberFormatter is not needed in this case, I have removed it. The pipeline has passed successfully, so I am moving this back to 'Needs Review.' Kindly review the changes.

  • 🇮🇳India narendraR Jaipur, India

    I thin numberFormatter is required on both modal and listing page to display numbers formatted correctly.
    Can we do something like:

            {Drupal.formatPlural(
              project.project_usage_total,
              `${numberFormatter.format(1)} site reports using this module`,
              `${numberFormatter.format(project.project_usage_total)} sites report using this module`
            )}
    
  • 🇮🇳India shalini_jha

    Sure , let me check.

  • Pipeline finished with Failed
    18 days ago
    Total: 633s
    #358724
  • Pipeline finished with Success
    18 days ago
    Total: 727s
    #358736
  • Pipeline finished with Success
    18 days ago
    Total: 510s
    #358786
  • 🇮🇳India shalini_jha

    Thank you, @narendrar, for your review and guidance. I have addressed the feedback and updated the test coverage accordingly. Moving this back to NR for your review. Kindly take a look at your convenience.

  • 🇮🇳India narendraR Jaipur, India

    This looks goos to me, except that on token list/grid it is showing as 590949 Active Installs, but it should be 590,949 Active Installs, so this also needs to be changed accordingly.

  • Pipeline finished with Success
    18 days ago
    Total: 350s
    #358867
  • 🇮🇳India shalini_jha

    Addressed the feedback for the install case as well. After applying the same approach for counting, the count is now displayed correctly, such as '590,949 Active Installs'. Kindly review.

  • 🇮🇳India narendraR Jaipur, India

    This MR needs rebase and a change needs to be done at one more place.

  • Pipeline finished with Canceled
    17 days ago
    Total: 209s
    #359875
  • Pipeline finished with Success
    17 days ago
    Total: 836s
    #359877
  • 🇮🇳India shalini_jha

    I have rebased and resolved the conflicts in the MR. Additionally, I have updated the list view case as part of the changes. I realized I had missed updating the second instance of the same code earlier, which was highlighted in the feedback. This has now been corrected in both places. Kindly review the updated changes.

  • 🇮🇳India narendraR Jaipur, India

    Changes looks good to me. Thanks for working on this issue. Moving it to RTBC.

  • 🇺🇸United States chrisfromredfin Portland, Maine

    This looks good. Leslie and I realized while manually testing, though it's going to be a follow-up, is that on the detail modal it's showing for 0 installs - it should be hiding altogether for 0 installs like on the cards. But again, that's a new issue.

  • Pipeline finished with Skipped
    11 days ago
    #364753
  • 🇺🇸United States chrisfromredfin Portland, Maine
  • 🇺🇸United States chrisfromredfin Portland, Maine

    thanks!

Production build 0.71.5 2024