Files
discourse/migrations/lib/common/date_helper.rb
Gerhard Schlager 17ba19c7ae REFACTOR: Code generator for migrations IntemerdiateDB
* Splits the existing script into multiple classes
* Adds command for generating IntermediateDB schema (`migrations/bin/cli schema generate`)
* Changes the syntax of the IntermediateDB schema config
* Adds validation for the schema config
* It uses YAML schema aka JSON schema to validate the config file
* It generates the SQL schema file and Ruby classes for storing data in the IntermediateDB
2025-04-07 17:22:36 +02:00

18 lines
456 B
Ruby

# frozen_string_literal: true
module Migrations
module DateHelper
def self.human_readable_time(seconds)
hours, remainder = seconds.divmod(3600)
minutes, seconds = remainder.divmod(60)
format("%02d:%02d:%02d", hours, minutes, seconds)
end
def self.track_time
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
yield
Process.clock_gettime(Process::CLOCK_MONOTONIC) - start_time
end
end
end