class Growbot::Web::Data

Attributes

database[RW]

Public Class Methods

new() click to toggle source
# File lib/growbot/web/data.rb, line 7
def initialize
end

Public Instance Methods

get() click to toggle source
# File lib/growbot/web/data.rb, line 10
      def get
        dataset = []
        query = <<-QUERY
          FOR row in readings
            FILTER row.moisture != 0
            FILTER row.light != 0
            FILTER row.time >= #{start_time}
            SORT row.time ASC
            RETURN row
        QUERY
        collection.query.execute(query).each do |document|
          dataset << document.to_h
        end
        dataset
      end

Private Instance Methods

collection() click to toggle source
# File lib/growbot/web/data.rb, line 37
def collection
  @collection ||= database[:readings]
end
start_time() click to toggle source
# File lib/growbot/web/data.rb, line 27
def start_time
  (Time.now - 6*24*60*60).to_i * 1000
end