]> source.dussan.org Git - rspamd.git/commitdiff
Write statfiles revisions to the runtime.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 26 Jan 2015 13:05:08 +0000 (13:05 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 26 Jan 2015 13:05:08 +0000 (13:05 +0000)
src/libstat/stat_internal.h
src/libstat/stat_process.c

index 985472d2c3a432e22ef802bd9088eaf037c8681f..82d2ee17489cb13d31d110fdd3966846c1a51d21 100644 (file)
@@ -46,6 +46,8 @@ struct rspamd_classifier_runtime {
        guint64 total_ham;
        guint64 processed_tokens;
        GList *st_runtime;
+       guint start_pos;
+       guint end_pos;
 };
 
 struct rspamd_token_result {
index 0151bb9797fda617bbb71035704b0ff98430e4db..524640e4e6e317db2c8522550fb9c12052bc7dc7 100644 (file)
@@ -98,7 +98,7 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx,
        gpointer backend_runtime;
        GList *cur, *st_list = NULL, *curst;
        GList *cl_runtimes = NULL;
-       guint result_size = 0;
+       guint result_size = 0, start_pos = 0, end_pos = 0;
        struct preprocess_cb_data cbdata;
 
        cur = g_list_first (task->cfg->classifiers);
@@ -131,7 +131,7 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx,
 
                cl_runtime->clcf = clcf;
 
-               curst = clcf->statfiles;
+               curst = st_list;
                while (curst != NULL) {
                        stcf = (struct rspamd_statfile_config *)curst->data;
 
@@ -151,11 +151,21 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx,
                        st_runtime->backend_runtime = backend_runtime;
                        st_runtime->backend = bk;
 
+                       if (stcf->is_spam) {
+                               cl_runtime->total_spam += bk->total_learns (backend_runtime,
+                                               bk->ctx);
+                       }
+                       else {
+                               cl_runtime->total_ham += bk->total_learns (backend_runtime,
+                                               bk->ctx);
+                       }
+
                        cl_runtime->st_runtime = g_list_prepend (cl_runtime->st_runtime,
                                        st_runtime);
                        result_size ++;
 
                        curst = g_list_next (curst);
+                       end_pos ++;
                }
 
                if (cl_runtime->st_runtime != NULL) {
@@ -165,6 +175,13 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx,
                        cl_runtimes = g_list_prepend (cl_runtimes, cl_runtime);
                }
 
+               /* Set positions in the results array */
+               cl_runtime->start_pos = start_pos;
+               cl_runtime->end_pos = end_pos;
+
+               start_pos = end_pos;
+
+               /* Next classifier */
                cur = g_list_next (cur);
        }