@cryptotaxi247 / netdata-1 / commits / 8bf58525b

fix the units when returning percentage of a group (#15105)

Costa Tsaousis committed May 26, 2023 at 20:33 UTC 8bf58525b178987d600f27c81076719ce1d252b6
2 files changed +10 -6
database/contexts/query_target.c
+1 -1
@@ -1049,7 +1049,7 @@ QUERY_TARGET *query_target_create(QUERY_TARGET_REQUEST *qtr) {
1049 qt->window.before = qt->request.before;
1050
1051 qt->window.options = qt->request.options;
1052 - if(query_target_has_percentage_of_instance(qt))
1052 + if(query_target_has_percentage_of_group(qt))
1053 qt->window.options &= ~RRDR_OPTION_PERCENTAGE;
1054
1055 rrdr_relative_window_to_absolute(&qt->window.after, &qt->window.before, &qt->window.now);
database/contexts/rrdcontext.h
+9 -5
@@ -524,11 +524,15 @@ bool rrdcontext_retention_match(RRDCONTEXT_ACQUIRED *rca, time_t after, time_t b
524
525 #define query_target_aggregatable(qt) ((qt)->window.options & RRDR_OPTION_RETURN_RAW)
526
527 -static inline bool query_target_has_percentage_of_instance(QUERY_TARGET *qt) {
528 - for(size_t g = 0; g < MAX_QUERY_GROUP_BY_PASSES ;g++)
529 - if(qt->request.group_by[g].group_by & RRDR_GROUP_BY_PERCENTAGE_OF_INSTANCE)
527 +static inline bool query_target_has_percentage_of_group(QUERY_TARGET *qt) {
528 + for(size_t g = 0; g < MAX_QUERY_GROUP_BY_PASSES ;g++) {
529 + if (qt->request.group_by[g].group_by & RRDR_GROUP_BY_PERCENTAGE_OF_INSTANCE)
530 return true;
531
532 + if (qt->request.group_by[g].aggregation == RRDR_GROUP_BY_FUNCTION_PERCENTAGE)
533 + return true;
534 + }
535 +
536 return false;
537 }
538
@@ -536,7 +540,7 @@ static inline bool query_target_needs_all_dimensions(QUERY_TARGET *qt) {
540 if(qt->request.options & RRDR_OPTION_PERCENTAGE)
541 return true;
542
539 - return query_target_has_percentage_of_instance(qt);
543 + return query_target_has_percentage_of_group(qt);
544 }
545
546 static inline bool query_target_has_percentage_units(QUERY_TARGET *qt) {
@@ -546,7 +550,7 @@ static inline bool query_target_has_percentage_units(QUERY_TARGET *qt) {
550 if((qt->request.options & RRDR_OPTION_PERCENTAGE) && !(qt->window.options & RRDR_OPTION_RETURN_RAW))
551 return true;
552
549 - return query_target_has_percentage_of_instance(qt);
553 + return query_target_has_percentage_of_group(qt);
554 }
555
556 #endif // NETDATA_RRDCONTEXT_H