reasoncorp / dossier

Ruby-based report generation/presentation Rails engine.
MIT License
385 stars 79 forks source link

Grouped information #48

Open scuciatto opened 9 years ago

scuciatto commented 9 years ago

How can I show grouped information in my report? I have the following sql:

SELECT team, player_name from players

And I want to show my report like this:

Team 1 Player 1 Player 2

Team 2 Player 1 Player 2

ninjarobert commented 9 years ago

We ran into this need as well.

What I ended up doing was I just added "grouped_results" and "grouped_raw_results" methods in my report class and referenced them in a custom report view. We built a result table for each group. We looped through them by doing

report.grouped_results.each_pair do |group, rows|

Those methods just used group_by on results.rows and raw_results.rows respectively.

adamhunter commented 9 years ago

Hey guys! Sorry I am a repo slum lord. I use https://github.com/adamhunter/dossier-segmenter to mange this type of groupings to the nth complexity. Unfortunately, there is no documentation. I will try and add some this weekend if it would be helpful for future reports.

ninjarobert commented 9 years ago

Ha, that's not a problem. I had to solve this somehow and that's the quickest thing I came up with.

I'll check this project out at a later date and possibly refactor what I've done.

ninjarobert commented 9 years ago

It might be a good time to add a Wiki page for add-on gems or related projects.