Statistics: only consider selected dives in HTML export statistics

If only selected dives were exported into HTML, the statistics would
nevertheless cover all dives. A counter-intuitive behavior. Fix by
adding a selected_only flag to calculate_stats_summary().

Reported-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-10-06 16:50:46 +02:00 committed by Dirk Hohndel
parent b61f6f66d8
commit df16866292
5 changed files with 8 additions and 6 deletions

View file

@ -3,7 +3,7 @@
*
* core logic for the Info & Stats page -
* char *get_minutes(int seconds);
* void calculate_stats_summary(struct stats_summary *out);
* void calculate_stats_summary(struct stats_summary *out, bool selected_only);
* void calculate_stats_selected(stats_t *stats_selection);
*/
#include "gettext.h"
@ -91,7 +91,7 @@ char *get_minutes(int seconds)
* Before first use, it should be initialized with init_stats_summary().
* After use, memory must be released with free_stats_summary().
*/
void calculate_stats_summary(struct stats_summary *out)
void calculate_stats_summary(struct stats_summary *out, bool selected_only)
{
int idx;
struct dive *dp;
@ -147,6 +147,8 @@ void calculate_stats_summary(struct stats_summary *out)
/* this relies on the fact that the dives in the dive_table
* are in chronological order */
for_each_dive (idx, dp) {
if (selected_only && !dp->selected)
continue;
process_dive(dp, &stats);
/* yearly statistics */