pub async fn write_alert(
	alert_data: Alert,
	monitor_id: Id,
	txn: &mut sqlx::Transaction<'_, sqlx::Any>,
) -> Result<()> {
	let mut txn = txn.begin().await?;
	let data = serde_json::to_string(&alert_data)?;
	sqlx::query(
		"
		 insert into alerts
		 	(id, monitor_id, data, sent, date)
		 values
		 	($1, $2, $3, 0, $4)
		",
	)
	.bind(alert_data.id.to_string())
	.bind(monitor_id.to_string())
	.bind(data)
	.bind(alert_data.timestamp)
	.execute(txn.borrow_mut())
	.await?;
	txn.commit().await?;
	Ok(())
}
/// Log the completion of an alert handling process
Log the completion of an alert handling process
Log the completion of an alert handling process
pub async fn write_alert(
	alert_data: Alert,
	monitor_id: Id,
	txn: &mut sqlx::Transaction<'_, sqlx::Any>,
) -> Result<()> {
	let mut txn = txn.begin().await?;
	let data = serde_json::to_string(&alert_data)?;
	sqlx::query(
		"
		 insert into alerts
		 	(id, monitor_id, data, sent, date)
		 values
		 	($1, $2, $3, 0, $4)
		",
	)
	.bind(alert_data.id.to_string())
	.bind(monitor_id.to_string())
	.bind(data)
	.bind(alert_data.timestamp)
	.execute(txn.borrow_mut())
	.await?;
	txn.commit().await?;
	Ok(())
}
pub async fn write_alert ( alert_data : Alert , monitor_id : Id , txn : & mut sqlx :: Transaction < ' _ , sqlx :: Any > , ) -> Result < ( ) > { let mut txn = txn . begin ( ) . await ? ; let data = serde_json :: to_string ( & alert_data ) ? ; sqlx :: query ( " " , ) . bind ( alert_data . id . to_string ( ) ) . bind ( monitor_id . to_string ( ) ) . bind ( data ) . bind ( alert_data . timestamp ) . execute ( txn . borrow_mut ( ) ) . await ? ; txn . commit ( ) . await ? ; Ok ( ( ) ) }
Log the completion of an alert handling process
Log the completion of an alert handling process
alert_data
Alert
monitor_id
Id
txn
&mut sqlx::Transaction<'_, sqlx::Any>