Skip to content

Commit

Permalink
Implement a new command to count up the totla number of records in th…
Browse files Browse the repository at this point in the history
…e database
  • Loading branch information
piroor committed Nov 21, 2014
1 parent c23d80b commit 8f353b0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/droonga/plugins/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ def handle(message)
step.handler = StatusHandler
step.collector = Collectors::Or
end

class NTotalRecordsHandler < Droonga::Handler
def handle(message)
n_records = 0
@context.database.tables.collect do |table|
n_records += table.size
end
{
"n_total_records" => n_records,
}
end
end

define_single_step do |step|
step.name = "system.n_total_records"
step.handler = NTotalRecordsHandler
step.collector = Collectors::Sum
end
end
end
end

0 comments on commit 8f353b0

Please sign in to comment.