Skip to content

SPIKE: move rake tasks business logic and leave tasks as executors #8598

Draft
scruti wants to merge 4 commits intomainfrom
extract-business-logic-from-rake-tasks
Draft

SPIKE: move rake tasks business logic and leave tasks as executors #8598
scruti wants to merge 4 commits intomainfrom
extract-business-logic-from-rake-tasks

Conversation

@scruti
Copy link
Copy Markdown
Collaborator

@scruti scruti commented Mar 12, 2026

Trello card URL

Changes in this PR:

Started with the existing backfilling tasks as an example.

The intention

I am trying to find a normalised way to approach our one-off/regular manually executed tasks/scripts for our service, given the recent pain caused by coverage tools struggling to play ball with Rake tasks logic testing.

The approach

  • Move the logic of the tasks to whatever ruby object is appropriate:
    • Service objects for "commands" (again, service objects are used a bit of a "stuff drawer")
    • Jobs for things to execute in the background.
    • etc.
  • Proper unit code testing of the logic in the ruby code, without Rake quirky issues
  • The rake task is left as a mere executor of the ruby code. And the task is namespaced in its appropriate area (EG: data.rake)

Data & Schema Changes

If this PR modifies data structures or validations, check the following:

  • Adds/removes model validations
  • Adds/removes database fields
  • Modifies Vacancy enumerables (phases, working patterns, job roles, key stages, etc.)
If any of the above options has changed then the author must check/resolve all of the following...

Integration Impact

Does this change affect any of these integrations?

  • DfE Analytics platform
  • Legacy imports mappings
  • DWP Find a Job export mappings
  • Publisher ATS API (may require mapping updates or API versioning)

User Experience & Data Integrity

Could this change impact:

  • Existing subscription alerts (will legacy subscription search filters break?)
  • Legacy vacancy copying (will copied vacancies fail new validations?)
  • In-progress drafts for Vacancies or Job Applications

The task become one more of the data tasks existing pattern in the rake
tasks list. The actual logic to egecute is moved to backfill namespaced
service objects. POROS tested with Rspec.
@scruti scruti changed the title Set backfill tasks as data task calling service SPIKE: move rake tasks business logic and leave tasks as executors Mar 12, 2026
Comment thread app/services/backfills/vacancy_geolocation.rb Outdated
scruti added 3 commits March 12, 2026 14:56
Since is internal Vacancy logic with no other dependencies or
complexity, it seems appropriate to tell "Vacancy" to backfill their
missing values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant