<commit_before>class EventChannel < Channel
  class << self
    def type_name
      'Events feed'
    end
  end

  def icon
    'calendar'
  end

  def service_id_name
    'Feed URL'
  end

  def client
    @client ||= Feedjira::Feed.fetch_and_parse(service_identifier)
  end

  def refresh_items
    client.entries.each do |entry|
      unless items.where(guid: entry.entry_id).exists?
        item = items.create(
          guid: entry.entry_id,
          title: entry.title,
          content: entry.content,
          description: entry.summary,
          link: Link.where(url: entry.url).first_or_create,
          published_at: entry.published
        )
        item.tag_names = (entry.categories) if entry.categories
        e = item.events.build(
          start_date: entry.start_date,
          end_date: entry.end_date,
        )
        e.location = Location.where(location: entry.location).first_or_create
        e.save
      end
    end
    log_refresh
  end
  handle_asynchronously :refresh_items
<commit_msg>Get info from rss feed<commit_after>class EventChannel < Channel
  class << self
    def type_name
      'Events feed'
    end
  end

  def icon
    'calendar'
  end

  def service_id_name
    'Feed URL'
  end

  def refresh_items
    client.entries.each do |entry|
      unless items.where(guid: entry.entry_id).exists?
        item = items.create(
          guid: entry.entry_id,
          title: entry.title,
          content: entry.content,
          description: entry.summary,
          link: Link.where(url: entry.url).first_or_create,
          published_at: entry.published
        )
        item.tag_names = (entry.categories) if entry.categories
        e = item.events.build(
          start_date: entry.start_date,
          end_date: entry.end_date,
        )
        e.location = Location.where(location: entry.location).first_or_create
        e.save
      end
    end
    log_refresh
  end
  handle_asynchronously :refresh_items

  private

  def client
    @client ||= Feedjira::Feed.fetch_and_parse(service_identifier)
  end

  def get_info
    if new_record? && client
      self.name = client.title
      self.description = client.description
      self.url = client.feed_url
    end
  end

{'fraction_non_alphanumeric': 0.0813589628967367, 'fraction_numerical': 0.0, 'mean_word_length': 2.2201438848920865, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3381368', 'n_tokens_mistral': 687, 'n_tokens_neox': 674, 'n_words': 154}