File tree Expand file tree Collapse file tree
app/services/solid_queue_monitor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,16 +81,19 @@ def fill_buckets(buckets, index_counts)
8181 # Cross-DB bucket index expression.
8282 # PostgreSQL: CAST((EXTRACT(EPOCH FROM col) - start) / interval AS INTEGER)
8383 # SQLite: CAST((CAST(strftime('%s', col) AS INTEGER) - start) / interval AS INTEGER)
84+ # MySQL: CAST((UNIX_TIMESTAMP(col) - start) / interval AS SIGNED)
8485 def bucket_index_expr ( column , start_epoch , interval_seconds )
85- if sqlite?
86+ if adapter? ( 'sqlite' )
8687 "CAST((CAST(strftime('%s', #{ column } ) AS INTEGER) - #{ start_epoch } ) / #{ interval_seconds } AS INTEGER)"
88+ elsif adapter? ( 'mysql' )
89+ "CAST((UNIX_TIMESTAMP(#{ column } ) - #{ start_epoch } ) / #{ interval_seconds } AS SIGNED)"
8790 else
8891 "CAST((EXTRACT(EPOCH FROM #{ column } ) - #{ start_epoch } ) / #{ interval_seconds } AS INTEGER)"
8992 end
9093 end
9194
92- def sqlite?
93- ActiveRecord ::Base . connection . adapter_name . downcase . include? ( 'sqlite' )
95+ def adapter? ( name )
96+ ActiveRecord ::Base . connection . adapter_name . downcase . include? ( name )
9497 end
9598 end
9699end
You can’t perform that action at this time.
0 commit comments