Skip to content

Commit 5544ebb

Browse files
authored
Speed up duration_seconds by removing... (#495)
1 parent 048ce1a commit 5544ebb

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

app/models/concerns/heartbeatable.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ def duration_seconds(scope = all)
212212
ELSE LEAST(EXTRACT(EPOCH FROM (to_timestamp(time) - to_timestamp(LAG(time) OVER (PARTITION BY #{group_expr} ORDER BY time)))), #{heartbeat_timeout_duration.to_i})
213213
END as diff")
214214
.where.not(time: nil)
215-
.order(time: :asc)
216215
.unscope(:group)
217216

218217
connection.select_all(
@@ -230,7 +229,6 @@ def duration_seconds(scope = all)
230229
ELSE LEAST(EXTRACT(EPOCH FROM (to_timestamp(time) - to_timestamp(LAG(time) OVER (ORDER BY time)))), #{heartbeat_timeout_duration.to_i})
231230
END as diff")
232231
.where.not(time: nil)
233-
.order(time: :asc)
234232

235233
connection.select_value("SELECT COALESCE(SUM(diff), 0)::integer FROM (#{capped_diffs.to_sql}) AS diffs").to_i
236234
end

0 commit comments

Comments
 (0)