Class: Tasks

Inherits:
DB
  • Object
show all
Defined in:
lib/tasks.rb

Instance Method Summary collapse

Methods inherited from DB

#create, #info, #initialize

Methods included from Timer

#last_mon, #now

Constructor Details

This class inherits a constructor from DB

Instance Method Details

#lastObject



3
4
5
6
7
8
9
# File 'lib/tasks.rb', line 3

def last
  @db.fetch("SELECT * FROM tasks AS T ORDER BY (SELECT MAX(ts) FROM 
    (SELECT notes.created_at AS ts FROM notes WHERE task_id = T.id 
      UNION SELECT subtasks.created_at AS ts FROM subtasks WHERE task_id = T.id 
      UNION SELECT subtasks.finished_at AS ts FROM subtasks WHERE task_id = T.id 
      UNION SELECT tasks.created_at AS ts FROM tasks WHERE id = T.id)) DESC LIMIT 0, 10;").to_a
end

#listObject



11
12
13
14
15
16
17
# File 'lib/tasks.rb', line 11

def list
  @db.fetch("SELECT * FROM tasks AS T ORDER BY (SELECT MAX(ts) FROM 
    (SELECT notes.created_at AS ts FROM notes WHERE task_id = T.id 
      UNION SELECT subtasks.created_at AS ts FROM subtasks WHERE task_id = T.id 
      UNION SELECT subtasks.finished_at AS ts FROM subtasks WHERE task_id = T.id 
      UNION SELECT tasks.created_at AS ts FROM tasks WHERE id = T.id)) DESC;").to_a
end