Refactor .module logic

Created on 22 October 2024, 3 months ago

Problem/Motivation

Currently the entire logic is written in .module file. which makes it difficult to troubleshoot.

Steps to reproduce

NA

Proposed resolution

Refactor the code/logic in smaller chunks for reusability and better understanding, using services.

Remaining tasks

  • Create MR & Request Review
  • Review & RTBC
  • Merge & Release

User interface changes

No

API changes

No

Data model changes

No

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India rajeshreeputra Pune

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

Merge Requests

Comments & Activities

  • Issue created by @rajeshreeputra
  • 🇮🇳India rajeshreeputra Pune

    Following are the methods needs to be moved to utility service, working on it will update and move in review.

    • _searchstax_add_tracking
    • _searchstax_search_alter_solr_query
    • _searchstax_is_searchstax_solr
    • _searchstax_get_query_keys
    • _searchstax_stringify_complex_keys
  • 🇮🇳India rajeshreeputra Pune

    All methods now added to service, waiting for 📌 Test Coverage: Fix PHPCS warnings. Active to land.

  • Pipeline finished with Success
    3 months ago
    Total: 2065s
    #318986
  • 🇮🇳India rajeshreeputra Pune

    The changes from 📌 Test Coverage: Fix PHPCS warnings. Active have been merged. There are a few related warnings, plan to address shortly. Currently awaiting the merge of 📌 Test Coverage: Fix cspell warnings. Active . Once that is complete, we will proceed with adding the test coverage for the service.

  • Pipeline finished with Success
    3 months ago
    Total: 153s
    #319030
  • Pipeline finished with Failed
    3 months ago
    Total: 634s
    #319461
  • Pipeline finished with Failed
    3 months ago
    Total: 207s
    #320333
  • 🇮🇳India rajeshreeputra Pune

    Waiting for 📌 Test coverage Active to land.

  • Pipeline finished with Success
    3 months ago
    Total: 228s
    #331606
  • Pipeline finished with Failed
    3 months ago
    Total: 256s
    #331608
  • Pipeline finished with Failed
    3 months ago
    Total: 163s
    #332033
  • Pipeline finished with Failed
    3 months ago
    Total: 2465s
    #332818
  • Pipeline finished with Canceled
    3 months ago
    Total: 134s
    #332851
  • Pipeline finished with Failed
    3 months ago
    Total: 215s
    #332852
  • Pipeline finished with Failed
    3 months ago
    Total: 3690s
    #332856
  • Pipeline finished with Failed
    3 months ago
    Total: 142s
    #332984
  • Pipeline finished with Failed
    3 months ago
    Total: 136s
    #333000
  • Pipeline finished with Failed
    3 months ago
    Total: 136s
    #333007
  • 🇮🇳India rajeshreeputra Pune

    Requesting review.

  • Pipeline finished with Failed
    3 months ago
    Total: 147s
    #333023
  • Pipeline finished with Failed
    3 months ago
    Total: 166s
    #333694
  • Pipeline finished with Canceled
    2 months ago
    Total: 566s
    #334884
  • Pipeline finished with Success
    2 months ago
    Total: 145s
    #334891
  • Pipeline finished with Success
    2 months ago
    Total: 178s
    #334900
  • Pipeline finished with Success
    2 months ago
    Total: 286s
    #334909
  • Pipeline finished with Success
    2 months ago
    Total: 319s
    #334913
  • Pipeline finished with Success
    2 months ago
    Total: 153s
    #334964
  • 🇦🇹Austria drunken monkey Vienna, Austria

    drunken monkey made their first commit to this issue’s fork.

  • 🇦🇹Austria drunken monkey Vienna, Austria

    Thanks for your work on this!
    I made a few updates and created a change record .

    There’s one more thing before I can merge this, though: The new service should have an interface that defines all the methods it provides, the implementations should then just be documented with {@inheritdoc}. Then only this interface should be used for any type-hinting. (It seems we should also add the interface FQN as an alias for the service identifier, to be in line with how Core does it?)
    Could you please make that final change?

    Otherwise, this looks good now, thanks again!

  • 🇮🇳India rajeshreeputra Pune

    Thank you for the review, will take a look and update accordingly.

  • 🇦🇹Austria drunken monkey Vienna, Austria

    I now added the interface, and also renamed the service class since SearchStaxUtilityService was a bit verbose.

    However, I also thought of something else: Does it really make sense to have alterSolrQuery() in the utility service if there is already another service, SearchSubscriber, which has a method just forwarding to it? Wouldn’t it make more sense to just have the whole code for this in the SearchSubscriber class itself and just call that service from the Solr query alter hook?
    Or is there a good reason not to do that? (I’d then also add an interface for the SearchSubscriber service that covers that method.)

    Finally, I’m not sure stringifyComplexKeys() needs to be public (and, thus, on the interface) as it’s really only used internally by the service class. Would it be OK with you if we made it protected?

  • 🇮🇳India rajeshreeputra Pune

    I believe we should continue keeping it in the service, as it might be beneficial in other ways in the future, although I don't have a strong reason for this approach at the moment.

    I also thought of something else: Does it really make sense to have alterSolrQuery() in the utility service if there is already another service, SearchSubscriber, which has a method just forwarding to it? Wouldn’t it make more sense to just have the whole code for this in the SearchSubscriber class itself and just call that service from the Solr query alter hook?

    Agree with you on making stringifyComplexKeys(), protected as it's used internally.

    Finally, I’m not sure stringifyComplexKeys() needs to be public (and, thus, on the interface) as it’s really only used internally by the service class. Would it be OK with you if we made it protected?

  • 🇦🇹Austria drunken monkey Vienna, Austria

    OK, then let’s keep it in the service, I have no strong feelings either way. I just changed the method visibility and then merged.
    Thanks again!

  • Pipeline finished with Skipped
    about 2 months ago
    #359163
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024