From: Vsevolod Stakhov Date: Sat, 9 Aug 2025 09:42:41 +0000 (+0100) Subject: [Fix] Try to fix learned order X-Git-Tag: 3.13.0~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d0c2a24ddc66c91021a5e61b81b9b0ee781f40a7;p=thirdparty%2Frspamd.git [Fix] Try to fix learned order --- diff --git a/src/libstat/backends/redis_backend.cxx b/src/libstat/backends/redis_backend.cxx index 302778bcbc..3a78de1dde 100644 --- a/src/libstat/backends/redis_backend.cxx +++ b/src/libstat/backends/redis_backend.cxx @@ -1275,12 +1275,27 @@ rspamd_redis_process_tokens(struct rspamd_task *task, } } else { - /* Binary classification: send both spam and ham labels for optimization */ - lua_createtable(L, 2, 0); - lua_pushstring(L, "H"); /* ham */ - lua_rawseti(L, -2, 1); - lua_pushstring(L, "S"); /* spam */ - lua_rawseti(L, -2, 2); + /* Binary classification: send labels in statfiles order to match parsing order */ + if (rt->stcf->clcf && rt->stcf->clcf->statfiles) { + lua_createtable(L, 0, 0); + GList *cur = rt->stcf->clcf->statfiles; + int lbl_idx = 1; + + while (cur) { + auto *sf = (struct rspamd_statfile_config *) cur->data; + lua_pushstring(L, get_class_label(sf)); + lua_rawseti(L, -2, lbl_idx++); + cur = g_list_next(cur); + } + } + else { + /* Fallback to the legacy order if statfiles are not available */ + lua_createtable(L, 2, 0); + lua_pushstring(L, "H"); /* ham */ + lua_rawseti(L, -2, 1); + lua_pushstring(L, "S"); /* spam */ + lua_rawseti(L, -2, 2); + } } lua_new_text(L, tokens_buf, tokens_len, false);