mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-05 20:48:58 +01:00
add analytics on the stats routes
This commit is contained in:
parent
22874ce300
commit
62240b7e19
@ -158,7 +158,14 @@ pub async fn delete_index(
|
|||||||
pub async fn get_index_stats(
|
pub async fn get_index_stats(
|
||||||
meilisearch: GuardedData<ActionPolicy<{ actions::STATS_GET }>, MeiliSearch>,
|
meilisearch: GuardedData<ActionPolicy<{ actions::STATS_GET }>, MeiliSearch>,
|
||||||
path: web::Path<String>,
|
path: web::Path<String>,
|
||||||
|
req: HttpRequest,
|
||||||
|
analytics: web::Data<dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
|
analytics.publish(
|
||||||
|
"Stats Seen".to_string(),
|
||||||
|
json!({ "per_index_uid": true }),
|
||||||
|
Some(&req),
|
||||||
|
);
|
||||||
let response = meilisearch.get_index_stats(path.into_inner()).await?;
|
let response = meilisearch.get_index_stats(path.into_inner()).await?;
|
||||||
|
|
||||||
debug!("returns: {:?}", response);
|
debug!("returns: {:?}", response);
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use actix_web::{web, HttpResponse};
|
use actix_web::{web, HttpRequest, HttpResponse};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use serde_json::json;
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
|
||||||
use meilisearch_lib::index::{Settings, Unchecked};
|
use meilisearch_lib::index::{Settings, Unchecked};
|
||||||
@ -9,6 +10,7 @@ use meilisearch_lib::MeiliSearch;
|
|||||||
use meilisearch_types::error::ResponseError;
|
use meilisearch_types::error::ResponseError;
|
||||||
use meilisearch_types::star_or::StarOr;
|
use meilisearch_types::star_or::StarOr;
|
||||||
|
|
||||||
|
use crate::analytics::Analytics;
|
||||||
use crate::extractors::authentication::{policies::*, GuardedData};
|
use crate::extractors::authentication::{policies::*, GuardedData};
|
||||||
|
|
||||||
mod api_key;
|
mod api_key;
|
||||||
@ -231,7 +233,14 @@ pub async fn running() -> HttpResponse {
|
|||||||
|
|
||||||
async fn get_stats(
|
async fn get_stats(
|
||||||
meilisearch: GuardedData<ActionPolicy<{ actions::STATS_GET }>, MeiliSearch>,
|
meilisearch: GuardedData<ActionPolicy<{ actions::STATS_GET }>, MeiliSearch>,
|
||||||
|
req: HttpRequest,
|
||||||
|
analytics: web::Data<dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
|
analytics.publish(
|
||||||
|
"Stats Seen".to_string(),
|
||||||
|
json!({ "per_index_uid": false }),
|
||||||
|
Some(&req),
|
||||||
|
);
|
||||||
let search_rules = &meilisearch.filters().search_rules;
|
let search_rules = &meilisearch.filters().search_rules;
|
||||||
let response = meilisearch.get_all_stats(search_rules).await?;
|
let response = meilisearch.get_all_stats(search_rules).await?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user