Skip to content

[$250] [HOLD for payment 2024-11-01] [Search v2.4] Refactor and simplify SearchUtils #50787

Description

@Kicu

I wanted to suggest a piece of refactoring that could be done to simplify the code.

Problem

We can all see that some of the ***Utils files can grow to be much too big. Examples

  • ReportUtils.ts - 8400 loc
  • OptionListUtils.ts - 2600 loc
  • PolicyUtils - 1100 loc

In these files it is hard to comprehend what specific function does, and they stop having a single well defined responsibility. Developers tend to just clone existing functions and change them for their specific use case, instead of using functions that are already there, because nobody can reasonably understand the file with 2k lines.

In Search we were putting all the helpers into SearchUtils file, which has started to grow to over 1000 lines.
However there is a lot of functions there that are unrelated to each other and there is no benefit in keeping them together in one file.

Solution

After reviewing all the functions inside mentioned utils, I noticed that they fall into 2 categories:

  • related to displaying search results and Search UI for the user
  • related to manipulating SearchQuery and building/formatting query and Advanced Filters

I would like to create a simple PR where I will split SearchUtils into two files:SearchUtils and SearchQueryUtils, each responsible only for the part described above☝️. There will be no common code shared between the two, these files can stay quite decoupled.

I hope thanks to this these files will be easier to work with and in the future.

CC @luacmartins @rayane-djouah can I get your opinion and if it's ok get the 👍
I expect this refactor to take no more than 2-3hrs and I have time to do it right now.

Platforms:

N/A

Screenshots/Videos

Add any screenshot/video evidence
Issue OwnerCurrent Issue Owner: @
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021852302356415625691
  • Upwork Job ID: 1852302356415625691
  • Last Price Increase: 2024-11-01
  • Automatic offers:
    • rayane-djouah | Contributor | 104692441

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2ExternalAdded to denote the issue can be worked on by a contributorNewFeatureSomething to build that is a new item.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions