update parameter name to folder_id and add report_id to report query url
This commit is contained in:
parent
322ed67a1e
commit
aea054e68e
|
@ -91,14 +91,14 @@ pub(crate) fn get_search_event_context_from_request(
|
|||
SearchEventType::Dashboards => Some(SearchEventContext::with_dashboard(
|
||||
query.get("dashboard_id").map(String::from),
|
||||
query.get("dashboard_name").map(String::from),
|
||||
query.get("dashboard_folder_id").map(String::from),
|
||||
query.get("dashboard_folder_name").map(String::from),
|
||||
query.get("folder_id").map(String::from),
|
||||
query.get("folder_name").map(String::from),
|
||||
)),
|
||||
SearchEventType::Alerts => Some(SearchEventContext::with_alert(
|
||||
query.get("alert_key").map(String::from),
|
||||
)),
|
||||
SearchEventType::Reports => Some(SearchEventContext::with_alert(
|
||||
query.get("report_key").map(String::from),
|
||||
query.get("report_id").map(String::from),
|
||||
)),
|
||||
_ => None,
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ pub static SMTP_CLIENT: Lazy<AsyncSmtpTransport<Tokio1Executor>> = Lazy::new(||
|
|||
transport_builder.build()
|
||||
});
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn generate_report(
|
||||
dashboard: &models::ReportDashboard,
|
||||
org_id: &str,
|
||||
|
@ -144,6 +145,7 @@ pub async fn generate_report(
|
|||
web_url: &str,
|
||||
timezone: &str,
|
||||
report_type: ReportType,
|
||||
report_name: &str,
|
||||
) -> Result<(Vec<u8>, String), anyhow::Error> {
|
||||
let dashboard_id = &dashboard.dashboard;
|
||||
let folder_id = &dashboard.folder;
|
||||
|
@ -219,9 +221,9 @@ pub async fn generate_report(
|
|||
sleep(Duration::from_secs(5)).await;
|
||||
|
||||
let timerange = &dashboard.timerange;
|
||||
let search_type = match report_type.clone() {
|
||||
ReportType::Cache => "ui",
|
||||
_ => "reports",
|
||||
let search_type_params = match report_type.clone() {
|
||||
ReportType::Cache => "search_type=ui".to_string(),
|
||||
_ => format!("search_type=reports&report_id={org_id}-{report_name}"),
|
||||
};
|
||||
|
||||
// dashboard link in the email should contain data of the same period as the report
|
||||
|
@ -230,7 +232,7 @@ pub async fn generate_report(
|
|||
let period = &timerange.period;
|
||||
let (time_duration, time_unit) = period.split_at(period.len() - 1);
|
||||
let dashb_url = format!(
|
||||
"{web_url}/dashboards/view?org_identifier={org_id}&dashboard={dashboard_id}&folder={folder_id}&tab={tab_id}&refresh=Off&searchtype={search_type}&period={period}&timezone={timezone}&var-Dynamic+filters=%255B%255D&print=true{dashb_vars}",
|
||||
"{web_url}/dashboards/view?org_identifier={org_id}&dashboard={dashboard_id}&folder={folder_id}&tab={tab_id}&refresh=Off&{search_type_params}&period={period}&timezone={timezone}&var-Dynamic+filters=%255B%255D&print=true{dashb_vars}",
|
||||
);
|
||||
log::debug!("dashb_url for dashboard {folder_id}/{dashboard_id}: {dashb_url}");
|
||||
|
||||
|
@ -281,7 +283,7 @@ pub async fn generate_report(
|
|||
}
|
||||
models::ReportTimerangeType::Absolute => {
|
||||
let url = format!(
|
||||
"{web_url}/dashboards/view?org_identifier={org_id}&dashboard={dashboard_id}&folder={folder_id}&tab={tab_id}&refresh=Off&searchtype={search_type}&from={}&to={}&timezone={timezone}&var-Dynamic+filters=%255B%255D&print=true{dashb_vars}",
|
||||
"{web_url}/dashboards/view?org_identifier={org_id}&dashboard={dashboard_id}&folder={folder_id}&tab={tab_id}&refresh=Off&{search_type_params}&from={}&to={}&timezone={timezone}&var-Dynamic+filters=%255B%255D&print=true{dashb_vars}",
|
||||
&timerange.from, &timerange.to
|
||||
);
|
||||
log::debug!("dashb_url for dashboard {folder_id}/{dashboard_id}: {url}");
|
||||
|
|
|
@ -79,6 +79,7 @@ pub async fn send_report(
|
|||
&report.email_details.dashb_url,
|
||||
timezone,
|
||||
report_type.clone(),
|
||||
&report_name,
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
|
|
@ -352,6 +352,7 @@ impl Report {
|
|||
&cfg.common.report_user_password,
|
||||
&self.timezone,
|
||||
no_of_recipients,
|
||||
&self.name,
|
||||
)
|
||||
.await?;
|
||||
self.send_email(&report.0, report.1).await
|
||||
|
@ -423,6 +424,7 @@ async fn generate_report(
|
|||
user_pass: &str,
|
||||
timezone: &str,
|
||||
no_of_recipients: usize,
|
||||
report_name: &str,
|
||||
) -> Result<(Vec<u8>, String), anyhow::Error> {
|
||||
let cfg = get_config();
|
||||
// Check if Chrome is enabled, otherwise don't save the report
|
||||
|
@ -488,10 +490,10 @@ async fn generate_report(
|
|||
tokio::time::sleep(Duration::from_secs(5)).await;
|
||||
|
||||
let timerange = &dashboard.timerange;
|
||||
let search_type = if no_of_recipients == 0 {
|
||||
"ui"
|
||||
let search_type_params = if no_of_recipients == 0 {
|
||||
"search_type=ui".to_string()
|
||||
} else {
|
||||
"reports"
|
||||
format!("search_type=reports&report_id={org_id}-{report_name}")
|
||||
};
|
||||
|
||||
// dashboard link in the email should contain data of the same period as the report
|
||||
|
@ -500,7 +502,7 @@ async fn generate_report(
|
|||
let period = &timerange.period;
|
||||
let (time_duration, time_unit) = period.split_at(period.len() - 1);
|
||||
let dashb_url = format!(
|
||||
"{web_url}/dashboards/view?org_identifier={org_id}&dashboard={dashboard_id}&folder={folder_id}&tab={tab_id}&refresh=Off&searchtype={search_type}&period={period}&timezone={timezone}&var-Dynamic+filters=%255B%255D&print=true{dashb_vars}",
|
||||
"{web_url}/dashboards/view?org_identifier={org_id}&dashboard={dashboard_id}&folder={folder_id}&tab={tab_id}&refresh=Off&{search_type_params}&period={period}&timezone={timezone}&var-Dynamic+filters=%255B%255D&print=true{dashb_vars}",
|
||||
);
|
||||
|
||||
let time_duration: i64 = time_duration.parse()?;
|
||||
|
@ -550,7 +552,7 @@ async fn generate_report(
|
|||
}
|
||||
ReportTimerangeType::Absolute => {
|
||||
let url = format!(
|
||||
"{web_url}/dashboards/view?org_identifier={org_id}&dashboard={dashboard_id}&folder={folder_id}&tab={tab_id}&refresh=Off&searchtype={search_type}&from={}&to={}&timezone={timezone}&var-Dynamic+filters=%255B%255D&print=true{dashb_vars}",
|
||||
"{web_url}/dashboards/view?org_identifier={org_id}&dashboard={dashboard_id}&folder={folder_id}&tab={tab_id}&refresh=Off&{search_type_params}&from={}&to={}&timezone={timezone}&var-Dynamic+filters=%255B%255D&print=true{dashb_vars}",
|
||||
&timerange.from, &timerange.to
|
||||
);
|
||||
(url.clone(), url)
|
||||
|
|
Loading…
Reference in New Issue