Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format report results #41

Open
TheRealNeil opened this issue Sep 15, 2022 · 2 comments
Open

Format report results #41

TheRealNeil opened this issue Sep 15, 2022 · 2 comments

Comments

@TheRealNeil
Copy link

When running a report, is it possible to specify / control the format of the results that are returned?

By default I am getting;
{ measure_name => measure_value, dimension1_name => dimension1_value, dimension2_name => dimension2_value

I would like to get a "values only" output;
{ [dimension1_value, dimension2_value] => measure_value }

@TheRealNeil
Copy link
Author

I managed to get the desired result with Hash[results.map { |r| [ r.fetch_values('dimension1_name', 'dimension2_name'), r.fetch('measure_name')] }] but I feel like there is probably a better way. I am really liking the gem and thought adding an option like raw_sql_results: true or results_with_labels: false to the report object might be an option. Would you be opposed to a PR if I can make it work?

@t27duck
Copy link
Owner

t27duck commented Sep 16, 2022

What would be the output in this "mode" if there's no dimensions defined in the report?

I wouldn't be against a PR to see how it would look, though perhaps this is better served in your app with via a decorator layer/utility class that does whatever formatting you want instead. This feels more like a very specific usecase for your implementation.

That said, I'm not sold on the naming. I feel there would be a better option name to describe what would come out of #result rather than results_with_labels ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants