Issue:
feat(analytics): analytics APIs

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
Set of analytics APIs of payments and refunds querying Postgres DB


### Additional Changes

- [x] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
To enhance hyperswitch feature set, analytics APIs are being added which will be hit from the dashboard and provide aggregated view of payment and refund transaction performance.

## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
This can be tested via the bundled dashboard or the postman API's

## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable


Resolution:
<think>
PR Context:
- Title: revert: fix(analytics): feat(analytics): analytics APIs
- Merged: 2023-11-03T11:59:33Z
- Files changed: 30 files
- Commits: 1 commits

Implementation approach:
Reverts juspay/hyperswitch#2676
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** revert: fix(analytics): feat(analytics): analytics APIs (#2777)
Files to modify:


**crates/api_models/src/analytics.rs**
  Remove:
    - struct: pub::NameDescription
    - struct: pub::GetInfoResponse
    - struct: pub::TimeRange
    - struct: pub::TimeSeries
    - struct: pub::GetPaymentMetricRequest
    - struct: pub::GetRefundMetricRequest
    - struct: pub::AnalyticsMetadata
    - struct: pub::GetPaymentFiltersRequest
    - struct: pub::PaymentFiltersResponse
    - struct: pub::FilterValue
    - struct: pub::GetRefundFilterRequest
    - struct: pub::RefundFiltersResponse
    - struct: pub::RefundFilterValue
    - struct: pub::MetricsResponse
    - enum: pub::Granularity
    - mod: pub::payments
    - mod: pub::refunds

**crates/api_models/src/analytics/payments.rs**
  Remove:
    - function: private::from
    - function: private::from
    - function: pub::new
    - function: private::hash
    - function: private::eq
    - struct: pub::PaymentFilters
    - struct: pub::PaymentSuccessRate
    - struct: pub::PaymentCount
    - struct: pub::PaymentSuccessCount
    - struct: pub::PaymentProcessedAmount
    - struct: pub::AvgTicketSize
    - struct: pub::PaymentMetricsBucketIdentifier
    - struct: pub::PaymentMetricsBucketValue
    - struct: pub::MetricsBucketResponse
    - enum: pub::PaymentDimensions
    - enum: pub::PaymentMetrics
    - impl: impl From<PaymentMetrics> for NameDescription
    - impl: impl From<PaymentDimensions> for NameDescription
    - impl: impl PaymentMetricsBucketIdentifier
    - impl: impl Hash for PaymentMetricsBucketIdentifier
    - impl: impl PartialEq for PaymentMetricsBucketIdentifier
    - mod: pub::metric_behaviour

**crates/api_models/src/analytics/refunds.rs**
  Remove:
    - function: private::from
    - function: private::from
    - function: private::hash
    - function: private::eq
    - function: pub::new
    - struct: pub::RefundFilters
    - struct: pub::RefundSuccessRate
    - struct: pub::RefundCount
    - struct: pub::RefundSuccessCount
    - struct: pub::RefundProcessedAmount
    - struct: pub::RefundMetricsBucketIdentifier
    - struct: pub::RefundMetricsBucketValue
    - struct: pub::RefundMetricsBucketResponse
    - enum: pub::RefundType
    - enum: pub::RefundDimensions
    - enum: pub::RefundMetrics
    - impl: impl From<RefundMetrics> for NameDescription
    - impl: impl From<RefundDimensions> for NameDescription
    - impl: impl Hash for RefundMetricsBucketIdentifier
    - impl: impl PartialEq for RefundMetricsBucketIdentifier
    - impl: impl RefundMetricsBucketIdentifier
    - mod: pub::metric_behaviour

**crates/api_models/src/lib.rs**
  Remove:
    - mod: pub::analytics

**crates/common_utils/src/custom_serde.rs**
  Remove:
    - function: pub::serialize
    - function: pub::deserialize
    - mod: pub::iso8601custom

**crates/router/src/analytics.rs**
  Remove:
    - function: pub::get_payment_metrics
    - function: pub::get_refund_metrics
    - function: pub::from_conf
    - function: private::default
    - enum: pub::AnalyticsProvider
    - enum: pub::AnalyticsConfig
    - impl: impl AnalyticsProvider
    - impl: impl Default for AnalyticsConfig
    - mod: private::core
    - mod: private::errors
    - mod: pub::metrics
    - mod: private::payments
    - mod: private::query
    - mod: private::refunds
    - mod: pub::routes
    - mod: private::sqlx
    - mod: private::types
    - mod: private::utils

**crates/router/src/analytics/core.rs**
  Remove:
    - function: pub::get_domain_info
    - function: pub::payment_filters_core
    - function: pub::refund_filter_core

**crates/router/src/analytics/errors.rs**
  Remove:
    - function: private::switch
    - enum: pub::AnalyticsError
    - impl: impl ErrorSwitch<ApiErrorResponse> for AnalyticsError

**crates/router/src/analytics/metrics.rs**
  Remove:
    - mod: pub::request

**crates/router/src/analytics/metrics/request.rs**
  Remove:
    - function: pub::add_attributes
    - function: pub::record_operation_time
    - function: pub::time_future

**crates/router/src/analytics/payments.rs**
  Remove:
    - trait: pub::PaymentAnalytics
    - mod: pub::accumulator
    - mod: private::core
    - mod: pub::filters
    - mod: pub::metrics
    - mod: pub::types

**crates/router/src/analytics/payments/accumulator.rs**
  Remove:
    - function: private::add_metrics_bucket
    - function: private::collect
    - function: private::add_metrics_bucket
    - function: private::collect
    - function: private::add_metrics_bucket
    - function: private::collect
    - function: private::add_metrics_bucket
    - function: private::collect
    - function: pub::collect
    - struct: pub::PaymentMetricsAccumulator
    - struct: pub::SuccessRateAccumulator
    - struct: pub::CountAccumulator
    - struct: pub::SumAccumulator
    - struct: pub::AverageAccumulator
    - trait: pub::PaymentMetricAccumulator
    - impl: impl PaymentMetricAccumulator for SuccessRateAccumulator
    - impl: impl PaymentMetricAccumulator for CountAccumulator
    - impl: impl PaymentMetricAccumulator for SumAccumulator
    - impl: impl PaymentMetricAccumulator for AverageAccumulator
    - impl: impl PaymentMetricsAccumulator

**crates/router/src/analytics/payments/core.rs**
  Remove:
    - function: pub::get_metrics

**crates/router/src/analytics/payments/filters.rs**
  Remove:
    - function: pub::get_payment_filter_for_dimension
    - struct: pub::FilterRow
    - trait: pub::PaymentFilterAnalytics

**crates/router/src/analytics/payments/metrics.rs**
  Remove:
    - function: private::load_metrics
    - struct: pub::PaymentMetricRow
    - trait: pub::PaymentMetricAnalytics
    - trait: pub::PaymentMetric
    - impl: impl PaymentMetric<T> for PaymentMetrics
    - mod: private::avg_ticket_size
    - mod: private::payment_count
    - mod: private::payment_processed_amount
    - mod: private::payment_success_count
    - mod: private::success_rate

**crates/router/src/analytics/payments/metrics/avg_ticket_size.rs**
  Remove:
    - function: private::load_metrics
    - struct: pub::AvgTicketSize
    - impl: impl PaymentMetric<T> for AvgTicketSize

**crates/router/src/analytics/payments/metrics/payment_count.rs**
  Remove:
    - function: private::load_metrics
    - struct: pub::PaymentCount
    - impl: impl super::PaymentMetric<T> for PaymentCount

**crates/router/src/analytics/payments/metrics/payment_processed_amount.rs**
  Remove:
    - function: private::load_metrics
    - struct: pub::PaymentProcessedAmount
    - impl: impl super::PaymentMetric<T> for PaymentProcessedAmount

**crates/router/src/analytics/payments/metrics/payment_success_count.rs**
  Remove:
    - function: private::load_metrics
    - struct: pub::PaymentSuccessCount
    - impl: impl super::PaymentMetric<T> for PaymentSuccessCount

**crates/router/src/analytics/payments/metrics/success_rate.rs**
  Remove:
    - function: private::load_metrics
    - struct: pub::PaymentSuccessRate
    - impl: impl super::PaymentMetric<T> for PaymentSuccessRate

**crates/router/src/analytics/payments/types.rs**
  Remove:
    - function: private::set_filter_clause
    - impl: impl QueryFilter<T> for PaymentFilters

**crates/router/src/analytics/query.rs**
  Remove:
    - function: private::set_filter_clause
    - function: private::set_group_by_clause
    - function: private::get_lowest_common_granularity_level
    - function: private::get_bucket_size
    - function: private::clip_to_start
    - function: private::clip_to_end
    - function: pub::new
    - function: pub::add_select_column
    - function: pub::set_distinct
    - function: pub::add_filter_clause
    - function: pub::add_bool_filter_clause
    - function: pub::add_custom_filter_clause
    - function: pub::add_filter_in_range_clause
    - function: pub::add_group_by_clause
    - function: pub::add_granularity_in_mins
    - function: private::get_filter_clause
    - function: private::get_select_clause
    - function: private::get_group_by_clause
    - function: pub::add_having_clause
    - function: pub::get_filter_type_clause
    - function: pub::build_query
    - function: pub::execute_query
    - struct: pub::QueryBuilder
    - enum: pub::TimeGranularityLevel
    - enum: pub::QueryBuildingError
    - enum: pub::PostProcessingError
    - enum: pub::Aggregate
    - enum: pub::FilterTypes
    - trait: pub::QueryFilter
    - trait: pub::GroupByClause
    - trait: pub::SeriesBucket
    - trait: pub::ToSql
    - impl: impl QueryFilter<T> for analytics_api::TimeRange
    - impl: impl GroupByClause<super::SqlxClient> for Granularity
    - impl: impl SeriesBucket for Granularity
    - impl: impl QueryBuilder<T>

**crates/router/src/analytics/refunds.rs**
  Remove:
    - trait: pub::RefundAnalytics
    - mod: pub::accumulator
    - mod: private::core
    - mod: pub::filters
    - mod: pub::metrics
    - mod: pub::types

**crates/router/src/analytics/refunds/accumulator.rs**
  Remove:
    - function: private::add_metrics_bucket
    - function: private::collect
    - function: private::add_metrics_bucket
    - function: private::collect
    - function: private::add_metrics_bucket
    - function: private::collect
    - function: pub::collect
    - struct: pub::RefundMetricsAccumulator
    - struct: pub::SuccessRateAccumulator
    - struct: pub::CountAccumulator
    - struct: pub::SumAccumulator
    - trait: pub::RefundMetricAccumulator
    - impl: impl RefundMetricAccumulator for CountAccumulator
    - impl: impl RefundMetricAccumulator for SumAccumulator
    - impl: impl RefundMetricAccumulator for SuccessRateAccumulator
    - impl: impl RefundMetricsAccumulator

**crates/router/src/analytics/refunds/core.rs**
  Remove:
    - function: pub::get_metrics

**crates/router/src/analytics/refunds/filters.rs**
  Remove:
    - function: pub::get_refund_filter_for_dimension
    - struct: pub::RefundFilterRow
    - trait: pub::RefundFilterAnalytics

**crates/router/src/analytics/refunds/metrics.rs**
  Remove:
    - function: private::load_metrics
    - struct: pub::RefundMetricRow
    - trait: pub::RefundMetricAnalytics
    - trait: pub::RefundMetric
    - impl: impl RefundMetric<T> for RefundMetrics
    - mod: private::refund_count
    - mod: private::refund_processed_amount
    - mod: private::refund_success_count
    - mod: private::refund_success_rate

**crates/router/src/analytics/refunds/metrics/refund_count.rs**
  Remove:
    - function: private::load_metrics
    - struct: pub::RefundCount
    - impl: impl super::RefundMetric<T> for RefundCount

**crates/router/src/analytics/refunds/metrics/refund_processed_amount.rs**
  Remove:
    - function: private::load_metrics
    - struct: pub::RefundProcessedAmount
    - impl: impl super::RefundMetric<T> for RefundProcessedAmount

**crates/router/src/analytics/refunds/metrics/refund_success_count.rs**
  Remove:
    - function: private::load_metrics
    - struct: pub::RefundSuccessCount
    - impl: impl super::RefundMetric<T> for RefundSuccessCount

**crates/router/src/analytics/refunds/metrics/refund_success_rate.rs**
  Remove:
    - function: private::load_metrics
    - struct: pub::RefundSuccessRate
    - impl: impl super::RefundMetric<T> for RefundSuccessRate

**crates/router/src/analytics/refunds/types.rs**
  Remove:
    - function: private::set_filter_clause
    - impl: impl QueryFilter<T> for RefundFilters

**crates/router/src/analytics/routes.rs**
  Remove:
    - function: pub::server
    - function: pub::get_info
    - function: pub::get_payment_metrics
    - function: pub::get_refunds_metrics
    - function: pub::get_payment_filters
    - function: pub::get_refund_filters
    - struct: pub::Analytics
    - impl: impl Analytics

**crates/router/src/analytics/sqlx.rs**
  Remove:
    - function: pub::from_conf
    - function: private::encode_by_ref
    - function: private::size_hint
    - function: private::decode
    - function: private::type_info
    - function: private::load_row
    - function: private::load_results
    - function: private::from_row
    - function: private::from_row
    - function: private::from_row
    - function: private::from_row
    - function: private::to_sql
    - function: private::to_sql
    - function: private::to_sql
    - struct: pub::SqlxClient
    - trait: pub::DbType
    - impl: impl SqlxClient
    - impl: impl Encode<'q, Postgres> for DBEnumWrapper<Type>
    - impl: impl Decode<'r, Postgres> for DBEnumWrapper<Type>
    - impl: impl sqlx::Type<Postgres> for DBEnumWrapper<Type>
    - impl: impl LoadRow<T> for SqlxClient
    - impl: impl super::payments::filters::PaymentFilterAnalytics for SqlxClient
    - impl: impl super::payments::metrics::PaymentMetricAnalytics for SqlxClient
    - impl: impl super::refunds::metrics::RefundMetricAnalytics for SqlxClient
    - impl: impl super::refunds::filters::RefundFilterAnalytics for SqlxClient
    - impl: impl AnalyticsDataSource for SqlxClient
    - impl: impl FromRow<'a, PgRow> for super::refunds::metrics::RefundMetricRow
    - impl: impl FromRow<'a, PgRow> for super::payments::metrics::PaymentMetricRow
    - impl: impl FromRow<'a, PgRow> for super::payments::filters::FilterRow
    - impl: impl FromRow<'a, PgRow> for super::refunds::filters::RefundFilterRow
    - impl: impl ToSql<SqlxClient> for PrimitiveDateTime
    - impl: impl ToSql<SqlxClient> for AnalyticsCollection
    - impl: impl ToSql<SqlxClient> for Aggregate<T>

**crates/router/src/analytics/types.rs**
  Remove:
    - function: private::as_ref
    - function: private::from_str
    - function: private::switch
    - function: private::switch
    - struct: pub::DBEnumWrapper
    - enum: pub::AnalyticsDomain
    - enum: pub::AnalyticsCollection
    - enum: pub::MetricsError
    - enum: pub::QueryExecutionError
    - enum: pub::FiltersError
    - trait: pub::RefundAnalytics
    - trait: pub::AnalyticsDataSource
    - trait: pub::LoadRow
    - impl: impl AsRef<T> for DBEnumWrapper<T>
    - impl: impl FromStr for DBEnumWrapper<T>
    - impl: impl ErrorSwitch<MetricsError> for QueryBuildingError
    - impl: impl ErrorSwitch<FiltersError> for QueryBuildingError

**crates/router/src/analytics/utils.rs**
  Remove:
    - function: pub::get_payment_dimensions
    - function: pub::get_refund_dimensions
    - function: pub::get_payment_metrics_info
    - function: pub::get_refund_metrics_info

**crates/router/src/configs/settings.rs**
  Modify existing code

**crates/router/src/lib.rs**
  Remove:
    - mod: private::analytics

**crates/router/src/routes.rs**
  Modify existing code

**crates/router/src/routes/app.rs**
  Modify existing code

**crates/router_env/src/lib.rs**
  Remove:
    - enum: pub::AnalyticsFlow
    - impl: impl FlowMetric for AnalyticsFlow

**crates/router_env/src/metrics.rs**
  Modify existing code