<commit_before>module API
  module V1
    class Articles < Grape::API

      before { detect_stuff_by_domain }
      before { authenticate! }
   
      resource :articles do

        helpers do 
          def default_from_date
            @article_created_at ||= Article.first.created_at
            @article_created_at
          end
        end

        # Collect comments from articles
        #
        # Parameters:
        #   from             - date where the search will begin. If nothing is passed the default date will be the date of the first article created
        #   oldest           - Collect the oldest comments from reference_id comment. If nothing is passed the newest comments are collected
        #   limit            - amount of comments returned. The default value is 20
        #
        # Example Request:
        #  GET /articles?from=2013-04-04-14:41:43&until=2014-04-04-14:41:43&limit=10&type=Blog
        get do
          from_date = DateTime.parse(params[:from]) if params[:from]
          until_date = DateTime.parse(params[:until]) if params[:until]
  
          if from_date.nil?
            begin_period = default_from_date
            end_period = until_date.nil? ? DateTime.now : until_date
          else
            begin_period = from_date
            end_period = DateTime.now
          end
  <commit_msg>remove unecessary helper for begin date definition<commit_after>module API
  module V1
    class Articles < Grape::API
      before { detect_stuff_by_domain }
      before { authenticate! }
   
      resource :articles do

        # Collect comments from articles
        #
        # Parameters:
        #   from             - date where the search will begin. If nothing is passed the default date will be the date of the first article created
        #   oldest           - Collect the oldest comments from reference_id comment. If nothing is passed the newest comments are collected
        #   limit            - amount of comments returned. The default value is 20
        #
        # Example Request:
        #  GET /articles?from=2013-04-04-14:41:43&until=2014-04-04-14:41:43&limit=10&type=Blog
        get do
          from_date = DateTime.parse(params[:from]) if params[:from]
          until_date = DateTime.parse(params[:until]) if params[:until]
  
          if from_date.nil?
            begin_period = Time.at(0).to_datetime
            end_period = until_date.nil? ? DateTime.now : until_date
          else
            begin_period = from_date
            end_period = DateTime.now
          end
  
{'fraction_non_alphanumeric': 0.0668229777256741, 'fraction_numerical': 0.02618210238374365, 'mean_word_length': 1.9425287356321839, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7622157', 'n_tokens_mistral': 718, 'n_tokens_neox': 662, 'n_words': 209}