pongdanaiNil / code-challenge-api

0 stars 0 forks source link

[Chore] Extract scraping logic from worker classes #5

Open olivierobert opened 1 year ago

olivierobert commented 1 year ago

Issue

While the keyword processing is correctly implemented asynchronously, the worker classes contain too many responsibilities making it harder to maintain and test. For instance, https://github.com/pongdanaiNil/code-challenge-api/blob/development/spec/sidekiq/search_keyword_job_spec.rb does not have any validations that the scraping logic works as intended but only verified that a job is enqueued, thus providing limited assurance.

Expected

The scraping logic should be housed in a Plain Old Ruby Object (POROs), such as service classes. You can read more about this type objects on our playbook: https://nimblehq.co/compass/development/code-conventions/ruby/ruby-on-rails/#services

pongdanaiNil commented 1 year ago

I have extracted scraping logic from the worker class to the service class and added a spec to validate service work as intended. You can check out this merged pull request. If there are any questions or suggestions, please let me know.

olivierobert commented 1 year ago

I have added comments to the pull request. It is an improvement indeed 😁