mirror of
http://ghproxy.cn/https://github.com/multunus/onemdm-server
synced 2025-12-06 10:14:59 +00:00
Ignore deleted devices while showing the App usage report
This commit is contained in:
@@ -4,6 +4,7 @@ class AppUsage < ActiveRecord::Base
|
|||||||
|
|
||||||
scope :app_usages_per_device_app_day, lambda {
|
scope :app_usages_per_device_app_day, lambda {
|
||||||
AppUsage.select(:package_name,:device_id,:used_on).
|
AppUsage.select(:package_name,:device_id,:used_on).
|
||||||
|
where("device_id IS NOT NULL").
|
||||||
order("used_on desc").
|
order("used_on desc").
|
||||||
order("device_id").
|
order("device_id").
|
||||||
order("package_name").
|
order("package_name").
|
||||||
|
|||||||
@@ -7,4 +7,13 @@ RSpec.describe AppUsage, type: :model do
|
|||||||
it { should validate_presence_of :usage_duration_in_seconds }
|
it { should validate_presence_of :usage_duration_in_seconds }
|
||||||
it { should validate_presence_of :used_on }
|
it { should validate_presence_of :used_on }
|
||||||
it { should belong_to :device }
|
it { should belong_to :device }
|
||||||
|
|
||||||
|
context "App Usage report" do
|
||||||
|
let!(:app_usage) { create(:app_usage,device_id: nil) }
|
||||||
|
it "Ignore Deleted devices" do
|
||||||
|
app_usage = AppUsage.app_usages_per_device_app_day
|
||||||
|
expect(app_usage).to be_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user