Class: Timelog

Inherits:
ApplicationRecord show all
Includes:
EachBatch, Importable, Sortable
Defined in:
app/models/timelog.rb

Constant Summary collapse

MAX_TOTAL_TIME_SPENT =

Gitlab::TimeTrackingFormatter.parse(“1y”) == 31557600 seconds 31557600 slightly deviates from (365 days * 24 hours/day * 60 minutes/hour * 60 seconds/minute)

31557600.seconds.to_i

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Instance Attribute Summary

Attributes included from Importable

#importing, #user_contributions

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, nullable_column?, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Class Method Details

.sort_by_field(field) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'app/models/timelog.rb', line 53

def self.sort_by_field(field)
  case field.to_s
  when 'spent_at_asc' then order_scope_asc(:spent_at)
  when 'spent_at_desc' then order_scope_desc(:spent_at)
  when 'time_spent_asc' then order_scope_asc(:time_spent)
  when 'time_spent_desc' then order_scope_desc(:time_spent)
  else order_by(field)
  end
end

Instance Method Details

#issuableObject



49
50
51
# File 'app/models/timelog.rb', line 49

def issuable
  issue || merge_request
end