]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: Use new var_expand
authorAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 6 Sep 2024 06:08:22 +0000 (09:08 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:14 +0000 (12:34 +0200)
Dropping %{domain} in favor of %{value | domain}

src/stats/stats-metrics.c
src/stats/stats-settings.c

index 048cd9c9532eda959f8815a5c09b4bd3c29591b1..6cd13076e00c076686801de7500c895339b4d7b3 100644 (file)
@@ -6,7 +6,7 @@
 #include "str-sanitize.h"
 #include "stats-dist.h"
 #include "time-util.h"
-#include "var-expand.h"
+#include "var-expand-new.h"
 #include "event-filter.h"
 #include "event-exporter.h"
 #include "settings.h"
@@ -596,14 +596,14 @@ label_by_mod_str(const struct stats_metric_settings_group_by *group_by,
        if (group_by->discrete_modifier == NULL)
                return value;
 
-       const struct var_expand_table table[] = {
-               { 'v', value, "value" },
-               { 'd', i_strchr_to_next(value, '@'), "domain" },
-               { '\0', NULL, NULL }
+       const struct var_expand_params params = {
+               .table = (const struct var_expand_table[]) {
+                       { .key = "value", .value = value },
+                       VAR_EXPAND_TABLE_END
+               },
        };
        string_t *str = t_str_new(128);
-       if (var_expand_with_table(str, group_by->discrete_modifier,
-                                 table, &error) < 0) {
+       if (var_expand_new(str, group_by->discrete_modifier, &params, &error) < 0) {
                i_error("Failed to expand discrete modifier for %s: %s",
                        group_by->field, error);
        }
index 66283803f266857dac22f6fcf49631f26df7d121..b1a62e3923705e4f419b13cbb5f0d89f902db4c8 100644 (file)
@@ -8,7 +8,7 @@
 #include "event-exporter.h"
 #include "array.h"
 #include "str.h"
-#include "var-expand.h"
+#include "var-expand-new.h"
 
 /* <settings checks> */
 #include "event-filter.h"
@@ -466,15 +466,15 @@ parse_metric_group_by_mod(pool_t pool,
        group_by->discrete_modifier = p_strdup(pool, params[0]);
 
        /* Check that the variables are valid */
-       const struct var_expand_table table[] = {
-               { 'v', "", "value" },
-               { 'd', "", "domain" },
-               { '\0', NULL, NULL }
+       const struct var_expand_params vparams = {
+               .table = (const struct var_expand_table[]) {
+                       { .key ="value", .value = "" },
+                       VAR_EXPAND_TABLE_END
+               },
        };
        const char *error;
        string_t *str = t_str_new(128);
-       if (var_expand_with_table(str, group_by->discrete_modifier,
-                                 table, &error) <= 0) {
+       if (var_expand_new(str, group_by->discrete_modifier, &vparams, &error) < 0) {
                *error_r = t_strdup_printf(
                        "Failed to expand discrete modifier for %s: %s",
                        group_by->field, error);