mirror of
http://ghproxy.cn/https://github.com/multunus/onemdm-server
synced 2025-12-06 10:14:59 +00:00
Add usage summary for each device
This commit is contained in:
@@ -16,7 +16,7 @@ class Device < ActiveRecord::Base
|
||||
scope :active, -> {where("last_heartbeat_recd_time > '#{Time.now.utc - ACTIVE_TIMEFRAME}'")}
|
||||
scope :missing, -> {where("last_heartbeat_recd_time < '#{Time.now.utc - ACTIVE_TIMEFRAME}'AND last_heartbeat_recd_time > '#{Time.now.utc - MISSING_TIMEFRAME}'")}
|
||||
scope :dead, -> {where("last_heartbeat_recd_time < '#{Time.now.utc - MISSING_TIMEFRAME}'")}
|
||||
|
||||
|
||||
def generate_access_token
|
||||
self.access_token = SecureRandom.uuid
|
||||
end
|
||||
@@ -40,4 +40,15 @@ class Device < ActiveRecord::Base
|
||||
self.status = Device.statuses.keys[2]
|
||||
end
|
||||
end
|
||||
|
||||
def app_usage_summary
|
||||
app_usage_data = []
|
||||
self.app_usages.app_usages_per_device_app_day.each do |key,value|
|
||||
app_usage_data << {device_id: key[0],
|
||||
package_name: key[1],
|
||||
used_on: key[2],
|
||||
usage: value}
|
||||
end
|
||||
app_usage_data
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user