Skip to content

Entities sync service #25

@dmitrytrager

Description

@dmitrytrager

Replicate providers, topics, tags from manifest using external IDs

ContentProviderSync:

  class ContentProviderSync
    def sync(provider_data)
      ContentProvider.find_or_initialize_by(external_id: provider_data["id"]).tap do |p|
        p.update!(name: provider_data["name"])
      end
    end
  end

TopicSync:

  class TopicSync
    def sync(topic_data, content_provider)
      Topic.find_or_initialize_by(external_id: topic_data["id"]).tap do |t|
        t.update!(
          content_provider: content_provider,
          title: topic_data["name"],
          # map other fields...
        )
        sync_tags(t, topic_data["tag_ids"])
      end
    end
  end

TagSync:

  class TagSync
    def sync(tag_data)
      Tag.find_or_initialize_by(external_id: tag_data["id"]).tap do |t|
        t.update!(name: tag_data["name"])
      end
    end
  end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions