group_symbols = ucl_object_typed_new (UCL_ARRAY);
while (g_hash_table_iter_next (&sit, &k, &v)) {
+ guint freq = 0;
+ gdouble tm = 0.0;
+
sym = v;
sym_obj = ucl_object_typed_new (UCL_OBJECT);
"description", 0, false);
}
+ if (rspamd_symbols_cache_stat_symbol (session->ctx->cfg->cache,
+ sym->name, &freq, &tm)) {
+ ucl_object_insert_key (sym_obj,
+ ucl_object_fromint (freq),
+ "frequency", 0, false);
+ ucl_object_insert_key (sym_obj,
+ ucl_object_fromdouble (tm),
+ "time", 0, false);
+ }
+
ucl_array_append (group_symbols, sym_obj);
}
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)
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