{
struct metric_result *metric_res;
struct metric *metric;
+ guint i;
metric_res = g_hash_table_lookup (task->results, name);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t) g_hash_table_unref,
metric_res->sym_groups);
- metric_res->checked = FALSE;
metric_res->metric = metric;
metric_res->grow_factor = 0;
metric_res->score = 0;
g_hash_table_insert (task->results, (gpointer) metric->name,
metric_res);
+
+ for (i = 0; i < METRIC_ACTION_MAX; i++) {
+ metric_res->actions_limits[i] = metric->actions[i].score;
+ }
+
metric_res->action = METRIC_ACTION_MAX;
return metric_res;
struct metric_result {
struct metric *metric; /**< pointer to metric structure */
double score; /**< total score */
- double required_score; /**< real required score */
double grow_factor; /**< current grow factor */
GHashTable *symbols; /**< symbols of metric */
GHashTable *sym_groups; /**< groups of symbols */
- gboolean checked; /**< whether metric result is consolidated */
- enum rspamd_metric_action action; /**< the current action */
+ gdouble actions_limits[METRIC_ACTION_MAX]; /**< set of actions for this metric */
+ enum rspamd_metric_action action; /**< the current action */
};
/**
m = mres->metric;
mres->action = rspamd_check_action_metric (task, mres->score,
- &mres->required_score, m);
+ &mres->actions_limits[METRIC_ACTION_REJECT], m);
action = mres->action;
is_spam = (action < METRIC_ACTION_GREYLIST);
"is_skipped", 0, false);
ucl_object_insert_key (obj, ucl_object_fromdouble (mres->score),
"score", 0, false);
- ucl_object_insert_key (obj, ucl_object_fromdouble (mres->required_score),
+ ucl_object_insert_key (obj, ucl_object_fromdouble (mres->actions_limits[METRIC_ACTION_REJECT]),
"required_score", 0, false);
ucl_object_insert_key (obj,
ucl_object_fromstring (rspamd_action_to_str (action)),
break;
case RSPAMD_LOG_SCORES:
res.len = rspamd_snprintf (scorebuf, sizeof (scorebuf), "%.2f/%.2f",
- mres->score, mres->required_score);
+ mres->score, mres->actions_limits[METRIC_ACTION_REJECT]);
res.begin = scorebuf;
break;
case RSPAMD_LOG_SYMBOLS:
if (mres) {
mres->action = rspamd_check_action_metric (task,
mres->score,
- &mres->required_score,
+ &mres->actions_limits[METRIC_ACTION_REJECT],
mres->metric);
if (mres->action == METRIC_ACTION_REJECT) {