rubyforgood / rubyforgood/skillrx-beacon

Orphan Cleanup Service

Open
#28 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cross-app sync
Dominant language
HTML
Stars
4
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Remove entities no longer in manifest

  class OrphanCleanup
    def cleanup(manifest)
      external_file_ids = manifest.dig_all("providers", "topics", "files", "id")
      external_topic_ids = manifest.dig_all("providers", "topics", "id")
      external_provider_ids = manifest["providers"].pluck("id")
      external_tag_ids = manifest["tags"].pluck("id")

      # ActiveStorage will purge attached blobs automatically
      TopicFile.where.not(external_id: external_file_ids).destroy_all
      Topic.where.not(external_id: external_topic_ids).destroy_all
      ContentProvider.where.not(external_id: external_provider_ids).destroy_all
      Tag.where.not(external_id: external_tag_ids).destroy_all
    end
  end

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the OrphanCleanup class and the code that supplies its manifest, then read how the provider, topic, file, and tag records are persisted. Verify the cleanup behavior against a manifest containing missing entities and confirm that records absent from the manifest are removed without affecting retained entities.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
backend, database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.