Skip to content

Commit cdd117e

Browse files
committed
Adding fallback in the event of empty results
1 parent c2596fc commit cdd117e

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

lib/tobias/evaluations/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def run(&block)
4444
results << run_each(name, query)
4545
end
4646

47-
to_markdown(results)
47+
to_markdown(results.compact)
4848
end
4949

5050
def run_each(query)

lib/tobias/evaluations/work_mem.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,20 @@ def run_each(name, query)
3636
end
3737
end
3838
end
39-
40-
# TODO: Add a warning message or something.
41-
raise "Couldn't figure out work_mem."
4239
end
4340

4441
def to_markdown(results)
42+
if results.empty?
43+
return <<~MARKDOWN
44+
## #{description}
45+
46+
I couldn't figure out the required `work_mem` setting for your query.
47+
48+
Please open an issue at https://github.com/binarycleric/tobias/issues
49+
and include your query script and copy of your database schema.
50+
MARKDOWN
51+
end
52+
4553
current_work_mem = Tobias::WorkMem.from_sql(database.fetch("SHOW work_mem").first[:work_mem])
4654

4755
table = TTY::Table.new(header: ["Query", "Required work_mem", "p99 Time", "Average"])

0 commit comments

Comments
 (0)