Skip to content

Commit 451153d

Browse files
committed
FIX: Re-implement ReportGenerator.params_to_hash
1 parent e0bb6b3 commit 451153d

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

lib/discourse_data_explorer/report_generator.rb

+1-17
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,10 @@ def self.generate_post(query_id, query_params, opts = {})
3535
build_report_post(query, table, attach_csv: opts[:attach_csv], result:)
3636
end
3737

38-
private
39-
4038
def self.params_to_hash(query_params)
4139
params = JSON.parse(query_params)
42-
params_hash = {}
43-
44-
if !params.blank?
45-
param_key, param_value = [], []
46-
params.flatten.each.with_index do |data, i|
47-
if i % 2 == 0
48-
param_key << data
49-
else
50-
param_value << data
51-
end
52-
end
53-
54-
params_hash = Hash[param_key.zip(param_value)]
55-
end
5640

57-
params_hash
41+
params.map { |p| p.is_a?(Hash) ? [p["key"], p["value"]] : p }.to_h
5842
end
5943

6044
def self.build_report_pms(query, table = "", targets = [], attach_csv: false, result: nil)

0 commit comments

Comments
 (0)