Class: Periods

Inherits:
Object
  • Object
show all
Defined in:
lib/minder/database/periods.rb

Instance Method Summary collapse

Instance Method Details

#by_id(id) ⇒ Object



2
3
4
# File 'lib/minder/database/periods.rb', line 2

def by_id(id)
  where(id: id)
end

#completed_pomodorosObject



6
7
8
9
10
# File 'lib/minder/database/periods.rb', line 6

def completed_pomodoros
  where(type: 'work')
    .where('started_at IS NOT NULL')
    .where('ended_at IS NOT NULL')
end

#pomodoros_todayObject



12
13
14
15
16
17
# File 'lib/minder/database/periods.rb', line 12

def pomodoros_today
  completed_pomodoros.
    where('ended_at BETWEEN ? AND ?',
          Time.now.strftime('%Y-%m-%d 00:00:00'),
          Time.now.strftime('%Y-%m-%d 23:59:59'))
end