Skip to content

Commit 8e36456

Browse files
committed
scope coding_only w/ valid timestamps
1 parent 5bd2c84 commit 8e36456

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/test_wakatime_service.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@
33
class TestWakatimeService
44
def initialize(user: nil, specific_filters: [], allow_cache: true, limit: 10, start_date: nil, end_date: nil, scope: nil, boundary_aware: false)
55
@scope = scope || Heartbeat.all
6+
@scope = @scope.coding_only
7+
@scope = @scope.with_valid_timestamps
68
@user = user
79
@boundary_aware = boundary_aware
810

911
@start_date = convert_to_unix_timestamp(start_date)
1012
@end_date = convert_to_unix_timestamp(end_date)
1113

12-
# apply with_valid_timestamps filter if no custom scope provided-- this is copied from query in stats_controller
13-
if scope.nil?
14-
@scope = @scope.with_valid_timestamps
15-
end
16-
1714
# Default to 1 year ago if no start_date provided or if no data exists
1815
@start_date = @start_date || @scope.minimum(:time) || 1.year.ago.to_i
1916
@end_date = @end_date || @scope.maximum(:time) || Time.current.to_i

0 commit comments

Comments
 (0)