<commit_before>class MetadataSync
  include Pethau::InitializeWith
  include Pethau::DefaultValueOf

  initialize_with :logger
  default_value_of :logger, NullLogger.instance

  def run
    @marples = client

    @marples.when 'panopticon', 'artefacts', 'updated' do |artefact|
      remote_id = artefact['id']
      logger.debug "Finding artefact with panopticon id #{remote_id}"
      publications = Publication.where panopticon_id: remote_id
      publication = publications.first
      if publication
        logger.debug "Denormalising metadata for publication #{publication.id}"
        publication.denormalise_metadata
        logger.debug "Denormalised metadata, saving publication"
        success = publication.save
        if success
          logger.into "Updated metadata for publication #{publication.id}"
        else
          logger.error "Couldn't save updated metadata for publication #{publication.id}"
        end
      else
        logger.error "Couldn't find publication, bit odd. Ignoring message."
      end
    end
    logger.info "Started MetadataSync client..."
    @marples.join
  end

  def client
    transport = Messenger.transport<commit_msg>Fix another of craig's typos ;-)<commit_after>class MetadataSync
  include Pethau::InitializeWith
  include Pethau::DefaultValueOf

  initialize_with :logger
  default_value_of :logger, NullLogger.instance

  def run
    @marples = client

    @marples.when 'panopticon', 'artefacts', 'updated' do |artefact|
      remote_id = artefact['id']
      logger.debug "Finding artefact with panopticon id #{remote_id}"
      publications = Publication.where panopticon_id: remote_id
      publication = publications.first
      if publication
        logger.debug "Denormalising metadata for publication #{publication.id}"
        publication.denormalise_metadata
        logger.debug "Denormalised metadata, saving publication"
        success = publication.save
        if success
          logger.info "Updated metadata for publication #{publication.id}"
        else
          logger.error "Couldn't save updated metadata for publication #{publication.id}"
        end
      else
        logger.error "Couldn't find publication, bit odd. Ignoring message."
      end
    end
    logger.info "Started MetadataSync client..."
    @marples.join
  end

  def client
    transport = Messenger.transport
{'fraction_non_alphanumeric': 0.0751371886872098, 'fraction_numerical': 0.0, 'mean_word_length': 3.0791738382099827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4512714', 'n_tokens_mistral': 632, 'n_tokens_neox': 621, 'n_words': 186}