]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Return number of hits for a symbol when querying
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 20 Jun 2017 07:47:45 +0000 (08:47 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 20 Jun 2017 07:47:45 +0000 (08:47 +0100)
src/controller.c
src/libserver/symbols_cache.c
src/libserver/symbols_cache.h

index b72f0ad4fe3a557c1aaabf14c4d982f8d7b22d4e..3d88aa090abc02db53a0a3c8ec22cdcf5e23b399 100644 (file)
@@ -816,7 +816,7 @@ rspamd_controller_handle_symbols (struct rspamd_http_connection_entry *conn_ent,
                        }
 
                        if (rspamd_symbols_cache_stat_symbol (session->ctx->cfg->cache,
-                                       sym->name, &freq, &freq_dev, &tm)) {
+                                       sym->name, &freq, &freq_dev, &tm, NULL)) {
                                ucl_object_insert_key (sym_obj,
                                                ucl_object_fromdouble (freq),
                                                "frequency", 0, false);
index 8df440d1c61ba2973c1d3bbcd3bd96a0d0ee54d8..0728d0ee66b57afdcd4bf408cd4e7d587b39c285 100644 (file)
@@ -2136,10 +2136,8 @@ rspamd_symbols_cache_find_symbol (struct symbols_cache *cache, const gchar *name
 
 gboolean
 rspamd_symbols_cache_stat_symbol (struct symbols_cache *cache,
-               const gchar *name,
-               gdouble *frequency,
-               gdouble *freq_stddev,
-               gdouble *tm)
+               const gchar *name, gdouble *frequency, gdouble *freq_stddev,
+               gdouble *tm, guint *nhits)
 {
        struct cache_item *item;
 
@@ -2156,6 +2154,10 @@ rspamd_symbols_cache_stat_symbol (struct symbols_cache *cache,
                *freq_stddev = sqrt (item->st->stddev_frequency);
                *tm = item->st->time_counter.mean;
 
+               if (nhits) {
+                       *nhits = item->st->hits;
+               }
+
                return TRUE;
        }
 
index b003eebab4f8a4876a96b89ebea6c38332e27b03..b71c6e9b96390f7dec9cb47fb1d0dbe95cebb5ea 100644 (file)
@@ -141,10 +141,8 @@ gint rspamd_symbols_cache_find_symbol (struct symbols_cache *cache,
  * @return
  */
 gboolean rspamd_symbols_cache_stat_symbol (struct symbols_cache *cache,
-               const gchar *name,
-               gdouble *frequency,
-               gdouble *freq_stddev,
-               gdouble *tm);
+               const gchar *name, gdouble *frequency, gdouble *freq_stddev,
+               gdouble *tm, guint *nhits);
 /**
  * Find symbol in cache by its id
  * @param cache