<commit_before>require "active_support/core_ext/numeric/time"

module KgDatawarehouse
  class TimeOfDaySecondsExpandedDimension < ActiveRecord::Base
    self.table_name = :kg_datawarehouse_time_of_day_seconds_expanded_dimensions
    self.primary_key = :time_of_day_key
    
    def self.fill
      KgDatawarehouse::TimeOfDaySecondsDimension.destroy_all # delete existing data from table
      time_start = Time.parse("2000-01-01 00:00:00 -0000")
      
      ActiveRecord::Base.transaction do
        (0..108000).each do |i|
          new_time = KgDatawarehouse::TimeOfDaySecondsExpandedDimension.new
          hour = (i/3600).floor
          minutes_since_midnight = (i/60).floor
          seconds_since_midnight = i
          minute = (minutes_since_midnight-hour*60)
          second = (seconds_since_midnight-hour*3600)
          new_time.time_of_day_key                   = i
          new_time.hour_24                           = hour
          new_time.hour                              = hour
          new_time.hour_24_zero_padded               = hour.to_s.rjust(2,"0")
          new_time.hour_zero_padded                  = hour.to_s.rjust(2,"0")
          new_time.hour_minute_24                    = hour.to_s+":"+minute.to_s.rjust(2,"0")
          new_time.hour_minute                       = hour.to_s+":"+minute.to_s.rjust(2,"0")
          new_time.hour_minute_second_24             = hour.to_s+":"+minute.to_s.rjust(2,"0")+":"+second.to_s.rjust(2,"0")
          new_time.hour_minute_second                = hour.to_s+":"+minute.to_s.rjust(2,"0")+":"+second.to_s.rjust(2,"0")
          new_time.hour_minute_24_zero_padded        = hour.to_s.rjust(2,"0")+":"+minute.to_s.rjust(2,"0")
          new_time.hour_minute_zero_padded           = hour.to_s.rjust(2,"0")+":"+minute.to_s.rjust(2,"0")
          new_time.hour_minute_second_24_zero_padded = hour.to_s.rjust(2,"0")+":"+minute.to_s.rjust(2,"0")+":"+second.to_s.rjust(2,"0")
          new_time.hour_minute_second_zero_padded    = hour.to_s.rjust(2,"0")+":"+minute.to_s.rjust(2,"0")+":"+second.to_s.rjust(2,"0")
          new_time.minute                            = minute
          new_time.minute_zero_padded                = minute.to_s.rjust(2,"0")
          new_time.minutes_since_midnight            = minutes_since_midnight<commit_msg>fix wrong hour in expanded dimensions fill methods<commit_after>require "active_support/core_ext/numeric/time"

module KgDatawarehouse
  class TimeOfDaySecondsExpandedDimension < ActiveRecord::Base
    self.table_name = :kg_datawarehouse_time_of_day_seconds_expanded_dimensions
    self.primary_key = :time_of_day_key
    
    def self.fill
      KgDatawarehouse::TimeOfDaySecondsDimension.destroy_all # delete existing data from table
      time_start = Time.parse("2000-01-01 00:00:00 -0000")
      
      ActiveRecord::Base.transaction do
        (0..108000).each do |i|
          new_time = KgDatawarehouse::TimeOfDaySecondsExpandedDimension.new
          hour = (i/3600).floor
          minutes_since_midnight = (i/60).floor
          seconds_since_midnight = i
          minute = (minutes_since_midnight-hour*60)
          second = (seconds_since_midnight-hour*3600-minute*60)
          new_time.time_of_day_key                   = i
          new_time.hour_24                           = hour
          new_time.hour                              = hour
          new_time.hour_24_zero_padded               = hour.to_s.rjust(2,"0")
          new_time.hour_zero_padded                  = hour.to_s.rjust(2,"0")
          new_time.hour_minute_24                    = hour.to_s+":"+minute.to_s.rjust(2,"0")
          new_time.hour_minute                       = hour.to_s+":"+minute.to_s.rjust(2,"0")
          new_time.hour_minute_second_24             = hour.to_s+":"+minute.to_s.rjust(2,"0")+":"+second.to_s.rjust(2,"0")
          new_time.hour_minute_second                = hour.to_s+":"+minute.to_s.rjust(2,"0")+":"+second.to_s.rjust(2,"0")
          new_time.hour_minute_24_zero_padded        = hour.to_s.rjust(2,"0")+":"+minute.to_s.rjust(2,"0")
          new_time.hour_minute_zero_padded           = hour.to_s.rjust(2,"0")+":"+minute.to_s.rjust(2,"0")
          new_time.hour_minute_second_24_zero_padded = hour.to_s.rjust(2,"0")+":"+minute.to_s.rjust(2,"0")+":"+second.to_s.rjust(2,"0")
          new_time.hour_minute_second_zero_padded    = hour.to_s.rjust(2,"0")+":"+minute.to_s.rjust(2,"0")+":"+second.to_s.rjust(2,"0")
          new_time.minute                            = minute
          new_time.minute_zero_padded                = minute.to_s.rjust(2,"0")
          new_time.minutes_since_midnight            = minutes_since_midnight
{'fraction_non_alphanumeric': 0.12781471155908214, 'fraction_numerical': 0.03774394166845379, 'mean_word_length': 2.3290506780870808, 'pattern_counts': {'":': 24, '<': 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': '376244', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1613, 'n_words': 150}