Make relevance the default sort

Created on 17 September 2024, 2 months ago

Problem/Motivation

The default sort order is still "Most Popular" even after removing the Mock as the default plugin and switching to the Drupal.org JSON:API as the default. This backend can sort by Relevance as the default, even without a keyword being used in the query. Relevance can then be tweaked based on what we want (i.e. Popularity), which means we then don't need "Most installed" (Most Popular) any more either.

Steps to reproduce

Open PB. Do a search for the module "field permissions" - note that field permissions is in the fifth spot. Change the sort to relevance and you will see something that aligns more closely.

Proposed resolution

  • make Relevance the default sort option
  • remove the A-Z and Z-A sort options
  • remove the Most popular sort option
๐Ÿ“Œ Task
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
  • Pipeline finished with Failed
    2 months ago
    Total: 528s
    #285695
  • Pipeline finished with Failed
    2 months ago
    Total: 1018s
    #285715
  • First commit to issue fork.
  • Pipeline finished with Failed
    about 1 month ago
    Total: 532s
    #308919
  • Pipeline finished with Canceled
    about 1 month ago
    #309037
  • Pipeline finished with Failed
    about 1 month ago
    #309040
  • Pipeline finished with Failed
    about 1 month ago
    Total: 554s
    #309282
  • Pipeline finished with Failed
    about 1 month ago
    Total: 385s
    #311235
  • Pipeline finished with Failed
    about 1 month ago
    Total: 558s
    #311300
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    Copied from slack thread: https://drupal.slack.com/archives/C01UHB4QG12/p1729069688461429

    @Utkarsh_33 - @fjgarlin while working on https://www.drupal.org/project/project_browser/issues/3475056 ๐Ÿ“Œ Make relevance the default sort Active issue on which the testCategoryFiltering test is failing I came accross an issue with the json API. The api does not return any data (for the test environment) as we have changed the default sort to best_match instead of usage_total. What is the best way to fix this issue?

    @fjgarlin - well, the test is never hitting the jsonapi endpoint (by design), so maybe the issue is with the fixtures
    https://git.drupalcode.org/project/project_browser/-/blob/2.0.x/tests/mo...

    Checking that file, these are all the fixtures sorts that were generated:

    sort=-active_installs_total
    sort=title
    sort=-title
    sort=-created
    

    There are 50 queries in that file, and only 3 have no sort specified, which is what best_match is supposed to be.

    So, there are actually two things to do in here:
    - Change the queries for whatever is queried by PB
    - Regenerate the fixture files based on those queries

    (slack message was until here)
    --

    We didn't write any way to re-generate the fixtures as this is something that we've barely need, but it's relatively easy. You can create a PHP file with the same info as $path_to_fixture in the linked file above. The key of the array is the query to run against https://www.drupal.org/jsonapi + $key, and the value is the name of the file where to dump the contents, so tests/fixtures/drupalorg_jsonapi/ + $value

    Untested code:

    // This script is in the root of PB.
    $path_to_fixture = [
       "/index/project_modules/filter...super-long-query..." => "1.json",
       "/index/project_modules/filter...super-long-query2..." => "2.json"
    ];
    foreach ($path_to_fixture as $jsonapi_path => $fixture_file_name) {
       $contents = file_get_contents("https://www.drupal.org/jsonapi" . $jsonapi_path);
       if ($contents) {
          file_put_contents("tests/fixtures/drupalorg_jsonapi/" + $fixture_file_name, $contents);
       }
    }
    

    I also mentioned this in the MR, but if we want to only change the sortOptions for the DrupalorgJsonApi plugin, we should only change the method there, and not in the base plugin, as that would affect every plugin, where those other sort options might make sense.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    I could help with this and build some tooling to make it easier in the future but I wonโ€™t be able to get to it in a few days/weeks.

    That should be ok since the change is kind of tied to the improvements needed in the endpoint (which Iโ€™ll be doing ๐Ÿ˜…).

    But if anyone wants to give it a go Iโ€™m happy to review.

  • First commit to issue fork.
  • Pipeline finished with Failed
    30 days ago
    Total: 507s
    #319718
  • Pipeline finished with Failed
    30 days ago
    Total: 386s
    #319798
  • Pipeline finished with Failed
    29 days ago
    Total: 586s
    #320120
  • Pipeline finished with Failed
    29 days ago
    Total: 489s
    #320553
  • Pipeline finished with Failed
    29 days ago
    Total: 522s
    #320566
  • Pipeline finished with Failed
    29 days ago
    #320600
  • Pipeline finished with Failed
    29 days ago
    Total: 631s
    #320914
  • Pipeline finished with Success
    26 days ago
    Total: 556s
    #322637
  • Pipeline finished with Success
    26 days ago
    Total: 477s
    #323086
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia narendraR Jaipur, India

    Fixture regenerated, added some comments in DrupalOrgClientMiddleware so understand api requests. Moving it to NR.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    I just added some tiny feedback on the MR about a file that might not be related to these changes but it's here. Also, the MR has conflicts, so it might need a rebase.

    Last but not least, it'd be great to add some documentation about the fixture regeneration, either in the readme file or somewhere else, so when we need to do it again in the future we don't need to be going back in the git history or old issues.

    Setting back to "Needs work" based on all the above.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia lavanyatalwar

    Working on the suggested changes.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia lavanyatalwar

    Worked upon the Readme.md and deleted unnecessary files.

  • Pipeline finished with Success
    24 days ago
    Total: 494s
    #324912
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    The MR still shows conflicts (part of the feedback given on #10) and it's not mergable. It might need a rebase.

    The readme additions don't seem to reflect what needs to be done to regenerate the fixtures. I think it might make more sense to revert those changes and give @NarendraR a clean slate to document what he did, as "creating/editing massive json files" is definitely not the way to do this.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia lavanyatalwar

    Apologies for the confusion. I'll just revert the changes to ensure it doesn't interrupt your work.

  • Pipeline finished with Success
    24 days ago
    Total: 457s
    #324957
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    No worries. Thanks for reverting.

  • Pipeline finished with Success
    19 days ago
    #329306
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    I think we should have something in the readme file about the steps you followed to regenerate the fixtures. Did you do it manually? Did you script it? If you script it, which script did you use? This is something that might be needed in the future, and the process should be relatively issue, without going via git history / issue comments.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia narendraR Jaipur, India
  • Pipeline finished with Success
    19 days ago
    #329385
  • Pipeline finished with Failed
    18 days ago
    #329959
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    I moved the mapping of query => file to a class constant so it can easily be reused, and I created a helper script to regenerate the fixtures based on my comment in #5.

    I also documented how to use the script in the readme file.

  • Pipeline finished with Failed
    18 days ago
    #330010
  • Pipeline finished with Failed
    18 days ago
    #330013
  • Pipeline finished with Failed
    18 days ago
    #330022
  • Pipeline finished with Failed
    18 days ago
    #330025
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    A new fixture file is introduced in ๐Ÿ“Œ Do not hardcode UUIDs in DrupalJsonApi plugin Active . If that issue is merged first, we will need to update the fixture generating script in here (as I coded to avoid conflicts with other issues).

    If this one gets merged first, I'll take care of the rest on the other issue.

  • Pipeline finished with Skipped
    17 days ago
    #331129
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States chrisfromredfin Portland, Maine

    This is going in despite the failing tests since those are going to be fixed (flakiness, not true failures that I can tell) in ๐Ÿ› The multi-category filter needs to be an actual set of labeled checkboxes Active

  • Status changed to Fixed 3 days ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024