<commit_before>class TwitterController < ApplicationController
  include ERB::Util
  include ApplicationHelper
  include FiltersHelper
  # GET /twitter_timelines
  # GET /twitter_timelines.json
  def index
    if !user_signed_in? || ((!current_user.provider != nil) && (!current_user.provider.include? "twitter"))
      flash[:error] = t("twitter.err.notlogged")
      begin
        redirect_to(:back)
      rescue ActionController::RedirectBackError
        redirect_to root_path
      end
        return
    end
    
    userSource = Source.find("#{ZoneOntology::SOURCES_TYPE_TWITTER_TIMELINE}/#{current_user.login}")
    if userSource.to_json == "null"
      add_timeline_to_sources
      flash[:notice] = t("twitter.created")
    end

    sourceURI =  "#{ZoneOntology::SOURCES_TYPE_TWITTER_TIMELINE}/#{current_user.login}"

    search = nil
    Search.joins(:sources).where(["search_sources.value = ?", sourceURI]).each do |i|
      if i.filters.length == 0
        search = i
      end
    end

    if search == nil
      redirect_to url_for(:controller => :searches, :action => :create,  :sources => {:rss => [sourceURI]}, :searchName => "TwitterTimeline", :isNew => false), :method => 'post'
    else
      redirect_to url_for(search)
    end
  end
  
  def add_timeline_to_sources
    @source = Source.new(
      "#{ZoneOntology::SOURCES_TYPE_TWITTER_TIMELINE}/#{current_user.login}",
      {
        :owner => current_user.id, 
        :attrs => {
          RDF.type => ZoneOntology::SOURCES_TYPE_TWITTER_TIMELINE,
          ZoneOntology::SOURCES_TWITTER_TOKEN =>current_user.token, 
          ZoneOntology::SOURCES_TWITTER_TOKEN_SECRET => current_user.tokenSecret
        }
      }
    )
    @source.save
  end


end<commit_msg>print the disclaimer message when the user try to see his timeline<commit_after>class TwitterController < ApplicationController
  include ERB::Util
  include ApplicationHelper
  include FiltersHelper
  # GET /twitter_timelines
  # GET /twitter_timelines.json
  def index
    if !user_signed_in? || ((!current_user.provider != nil) && (!current_user.provider.include? "twitter"))
      flash[:error] = t("twitter.err.notlogged")
      begin
        redirect_to(:back)
      rescue ActionController::RedirectBackError
        redirect_to root_path
      end
        return
    end
    
    userSource = Source.find("#{ZoneOntology::SOURCES_TYPE_TWITTER_TIMELINE}/#{current_user.login}")
    if userSource.to_json == "null"
      add_timeline_to_sources
      flash[:notice] = t("twitter.created")
    end

    sourceURI =  "#{ZoneOntology::SOURCES_TYPE_TWITTER_TIMELINE}/#{current_user.login}"

    search = nil
    Search.joins(:sources).where(["search_sources.value = ?", sourceURI]).each do |i|
      if i.filters.length == 0
        search = i
      end
    end

    if search == nil
      redirect_to url_for(:controller => :searches, :action => :create,  :sources => {:rss => [sourceURI]}, :searchName => "TwitterTimeline", :isNew => true), :method => 'post'
    else
      redirect_to url_for(search)
    end
  end
  
  def add_timeline_to_sources
    @source = Source.new(
      "#{ZoneOntology::SOURCES_TYPE_TWITTER_TIMELINE}/#{current_user.login}",
      {
        :owner => current_user.id, 
        :attrs => {
          RDF.type => ZoneOntology::SOURCES_TYPE_TWITTER_TIMELINE,
          ZoneOntology::SOURCES_TWITTER_TOKEN =>current_user.token, 
          ZoneOntology::SOURCES_TWITTER_TOKEN_SECRET => current_user.tokenSecret
        }
      }
    )
    @source.save
  end


end
{'fraction_non_alphanumeric': 0.11678004535147392, 'fraction_numerical': 0.0005668934240362812, 'mean_word_length': 3.1812796208530805, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '819970', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1135, 'n_words': 200}