feat(analytics): refactor and introduce analytics APIs to accommodate OrgLevel, MerchantLevel and ProfileLevel authentication (#5729)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Sampras Lopes <sampras.lopes@juspay.in>
This commit is contained in:
Sandeep Kumar
2024-09-03 15:53:04 +05:30
committed by GitHub
parent 98cfc13f53
commit 8ed942c6cd
63 changed files with 2884 additions and 1531 deletions

View File

@ -13,7 +13,7 @@ use super::{
health_check::HealthCheck,
payment_intents::{filters::PaymentIntentFilterRow, metrics::PaymentIntentMetricRow},
payments::{
distribution::PaymentDistributionRow, filters::FilterRow, metrics::PaymentMetricRow,
distribution::PaymentDistributionRow, filters::PaymentFilterRow, metrics::PaymentMetricRow,
},
query::{Aggregate, ToSql, Window},
refunds::{filters::RefundFilterRow, metrics::RefundMetricRow},
@ -244,10 +244,10 @@ impl TryInto<PaymentDistributionRow> for serde_json::Value {
}
}
impl TryInto<FilterRow> for serde_json::Value {
impl TryInto<PaymentFilterRow> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<FilterRow, Self::Error> {
fn try_into(self) -> Result<PaymentFilterRow, Self::Error> {
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse FilterRow in clickhouse results",
))
@ -415,15 +415,7 @@ impl TryInto<ActivePaymentsMetricRow> for serde_json::Value {
impl ToSql<ClickhouseClient> for PrimitiveDateTime {
fn to_sql(&self, _table_engine: &TableEngine) -> error_stack::Result<String, ParsingError> {
let format =
time::format_description::parse("[year]-[month]-[day] [hour]:[minute]:[second]")
.change_context(ParsingError::DateTimeParsingError)
.attach_printable("Failed to parse format description")?;
self.format(&format)
.change_context(ParsingError::EncodeError(
"failed to encode to clickhouse date-time format",
))
.attach_printable("Failed to format date time")
Ok(self.assume_utc().unix_timestamp().to_string())
}
}