Skip to content

Commit

Permalink
Fixed error with --pg-stat-statements and --min-calls - fixes #53
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Apr 19, 2024
1 parent 7c8f2ae commit 62f1c98
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.5 (unreleased)

- Fixed error with `--pg-stat-statements` and `--min-calls`

## 0.5.4 (2024-04-03)

- Fixed issue with processing over 500 query fingerprints (introduced in 0.5.3)
Expand Down
1 change: 1 addition & 0 deletions lib/dexter/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def parse_args(args)

o.separator "Processing options:"
o.integer "--interval", "time to wait between processing queries, in seconds", default: 60
# TODO change to integer in 0.6.0
o.float "--min-calls", "only process queries that have been called a certain number of times", default: 0
o.float "--min-time", "only process queries that have consumed a certain amount of DB time, in minutes", default: 0
o.separator ""
Expand Down
2 changes: 1 addition & 1 deletion lib/dexter/indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ def stat_statements
ORDER BY
1
SQL
execute(sql, params: [@min_time * 60000, @min_calls]).map { |q| q["query"] }
execute(sql, params: [@min_time * 60000, @min_calls.to_i]).map { |q| q["query"] }
end

def with_advisory_lock
Expand Down
1 change: 1 addition & 0 deletions test/input_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def test_pg_stat_statements
execute("SELECT pg_stat_statements_reset()")
execute("SELECT * FROM posts WHERE id = 1")
assert_dexter_output "Index found: public.posts (id)", ["--pg-stat-statements"]
assert_dexter_output "Index found: public.posts (id)", ["--pg-stat-statements", "--min-calls", "1"]
end

def test_no_source
Expand Down

0 comments on commit 62f1c98

Please sign in to comment.