기본적으로 ServerStatus라는 모델이 있으며 Google 차트로 전달할 객체를 만들어야합니다.레일스 - Google 차트의 동일한 테이블에서 객체 만들기
data_table.add_row([ datetime, success, failure])
날짜 시간 필드 generated_at
라고하고 success
및 failure
은 부울, 관련 카운트 (별도의 필드) 각각 모두 :
ServerStatus Schema:
# config_id :integer
# count :integer
# success :boolean
# failure :boolean
# generated_at :datetime
개체 형식으로 할 필요가있다. 두 번에게 generated_at 시간을 이런 식으로 추가합니다 이렇게
ServerStatus.find(:all, :conditions => {:config_id => options[:config_id], :success => true, :generated_at => options[:start_date].beginning_of_day..options[:end_date].end_of_day}, :order => 'generated_at ASC').each do |s|
ServerStatus.find(:all, :conditions => {:config_id => options[:config_id], :failure => true, :generated_at => options[:start_date].beginning_of_day..options[:end_date].end_of_day}, :order => 'generated_at ASC').each do |f|
data_table.add_row([ s.generated_at.in_time_zone('Pacific Time (US & Canada)'), s.count, f.count])
end
end
, 그래서 잘못 :failure => true
플롯의 그래프 :
나는 현재 다음을 수행하고있다. success = true
과 failure = true
을 모두 선택하고 시간에 매핑 할 때 Null 값을 고려하여 각각의 수를 generated_at
시간으로 매핑하는 방법은 무엇입니까?)
이 진정한 성공은 = 모든 곳 실패 찾을 곳
그런 다음 위의 단계에 의해 반환 된 두 개의 배열을 추가 할 진정한 =
1) 모든 찾을 :