From c1a32980153a8f90ce6e25fdf8ec7c8c769cd38a Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 1 Nov 2016 12:26:43 +0000 Subject: [Feature] Add frequency and time display to webui --- src/libserver/symbols_cache.c | 26 ++++++++++++++++++++++++++ src/libserver/symbols_cache.h | 12 ++++++++++++ 2 files changed, 38 insertions(+) (limited to 'src/libserver') diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c index 1313f0840..68b4ffa84 100644 --- a/src/libserver/symbols_cache.c +++ b/src/libserver/symbols_cache.c @@ -1934,6 +1934,32 @@ rspamd_symbols_cache_find_symbol (struct symbols_cache *cache, const gchar *name return -1; } +gboolean +rspamd_symbols_cache_stat_symbol (struct symbols_cache *cache, + const gchar *name, + guint *frequency, + gdouble *tm) +{ + struct cache_item *item; + + g_assert (cache != NULL); + + if (name == NULL) { + return FALSE; + } + + item = g_hash_table_lookup (cache->items_by_symbol, name); + + if (item != NULL) { + *frequency = item->frequency; + *tm = item->avg_time; + + return TRUE; + } + + return FALSE; +} + static gint rspamd_symbols_cache_find_symbol_parent (struct symbols_cache *cache, const gchar *name) diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h index 0b5ed3cb1..c9877a830 100644 --- a/src/libserver/symbols_cache.h +++ b/src/libserver/symbols_cache.h @@ -119,6 +119,18 @@ gboolean rspamd_symbols_cache_add_condition_delayed (struct symbols_cache *cache gint rspamd_symbols_cache_find_symbol (struct symbols_cache *cache, const gchar *name); +/** + * Get statistics for a specific symbol + * @param cache + * @param name + * @param frequency + * @param tm + * @return + */ +gboolean rspamd_symbols_cache_stat_symbol (struct symbols_cache *cache, + const gchar *name, + guint *frequency, + gdouble *tm); /** * Find symbol in cache by its id * @param cache -- cgit v1.2.3