<commit_before># @Author: <NAME>
# @Date:   2015-08-26 15:03:12
# @Last Modified by:   <NAME>
# @Last Modified time: 2016-03-31 09:21:09

module Query

  # statistic class to calculate to work time for a given week of the year
  class WeekQuery < Base

    # method to retrieve the worktime for a person for the given year and week
    # @param [Integer] id the id of the person
    # @param [Integer] year the requested year
    # @param [Integer] calendar_week the requested week of the year
    def self.get_weekly_worktime(id, year, calendar_week)
      days = calculate_start_and_end_day(year, calendar_week)
      get_interval_worktime(id, days, (7*24))
    end

    # method to calculate the time boundaries for the given week
    # @param [Integer] year the requested year
    # @param [Integer] calendar_week the requested week
    # @return [Hash] a hash containing the two time boundaries
    def self.calculate_start_and_end_day(year, calendar_week)
      start_time = get_monday_of_calendar_week(year, calendar_week)
      end_time = get_next_monday(start_time)
      {:actual => Time.new(start_time.year, start_time.month, start_time.day),
       :next => Time.new(end_time.year, end_time.month, end_time.day)}
    end

    private

    # method to calculate the lower time boundary for the given week
    # (the start of the week)
    # @param [Integer] year the requested year
    # @param [Integer] calendar_week the requested week of the year
    # @return [Time] the start of the monday in the requested week
    def self.get_monday_of_calendar_week(year, calendar_week)
      start = Time.new(year)

      # Monday of calendar week 1
      start = get_next_monday(start)
      start += (calendar_week - 2) * 7 * 60 * 60 * 24
    end

    # method to calculate the upper time boundary for the given week
    # (the end of the week)
    # @param [Time] time the start time of the requested week
    # @return [Time] the time of the monday of the follwing week
    def self.get_next_monday(time)<commit_msg>adjusted calculation in week_query<commit_after># @Author: <NAME>
# @Date:   2015-08-26 15:03:12
# @Last Modified by:   <NAME>
# @Last Modified time: 2016-08-29 16:28:09

module Query

  # statistic class to calculate to work time for a given week of the year
  class WeekQuery < Base

    # method to retrieve the worktime for a person for the given year and week
    # @param [Integer] id the id of the person
    # @param [Integer] year the requested year
    # @param [Integer] calendar_week the requested week of the year
    def self.get_weekly_worktime(id, year, calendar_week)
      days = calculate_start_and_end_day(year, calendar_week)
      get_interval_worktime(id, days, (7*24))
    end

    # method to calculate the time boundaries for the given week
    # @param [Integer] year the requested year
    # @param [Integer] calendar_week the requested week
    # @return [Hash] a hash containing the two time boundaries
    def self.calculate_start_and_end_day(year, calendar_week)
      start_time = get_monday_of_calendar_week(year, calendar_week)
      end_time = get_next_monday(start_time)
      {:actual => Time.new(start_time.year, start_time.month, start_time.day),
       :next => Time.new(end_time.year, end_time.month, end_time.day)}
    end

    private

    # method to calculate the lower time boundary for the given week
    # (the start of the week)
    # @param [Integer] year the requested year
    # @param [Integer] calendar_week the requested week of the year
    # @return [Time] the start of the monday in the requested week
    def self.get_monday_of_calendar_week(year, calendar_week)
      start = Time.new(year)

      # Monday of calendar week 1
      start = get_next_monday(start)
      start + (calendar_week - 2) * 7 * 60 * 60 * 24
    end

    # method to calculate the upper time boundary for the given week
    # (the end of the week)
    # @param [Time] time the start time of the requested week
    # @return [Time] the time of the monday of the follwing week
    def self.get_next_monday(time)
{'fraction_non_alphanumeric': 0.07792527040314651, 'fraction_numerical': 0.01966568338249754, 'mean_word_length': 3.384698275862069, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '7284506', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1218, 'n_words': 466}