Skip to content

Commit

Permalink
added method for returning all events, renamed method for fetching ev…
Browse files Browse the repository at this point in the history
…ents related to a check
  • Loading branch information
auxesis committed Dec 27, 2009
1 parent 4e37891 commit cfa9d61
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/flapjack/persistence/sqlite3/sqlite3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def all_check_relationships
end

# events
def all_events(id)
def all_events_for(id)
results = @db.execute2(%(SELECT * FROM "events" WHERE check_id = #{id}))

records = results[1..-1].map do |values|
Expand All @@ -93,6 +93,20 @@ def all_events(id)
records
end

def all_events
results = @db.execute2(%(SELECT * FROM "events";))

records = results[1..-1].map do |values|
hash = {}
values.each_with_index do |value, index|
hash[results[0][index]] = value
end
hash
end

records
end

def create_event(result)
@db.execute(%(INSERT INTO "events" ("check_id", "created_at") VALUES ("#{result.result.check_id}", "#{Time.now}")))
true
Expand Down

0 comments on commit cfa9d61

Please sign in to comment.