Issue:
fix: add time_range constraint to retrieve payment attempt list

Currently, to retrieve the total count for payments, we use a query that gets the total count of attempts based on the last active attempt ID. To enhance performance, we need to add a time_range to the query. This will ensure that the query is executed only for the given time constraint, improving efficiency by narrowing the search to a specific time period.

Resolution:
<think>
PR Context:
- Title: fix(payments): add time range in list payment attempts query
- Merged: 2024-09-19T18:20:57Z
- Files changed: 30 files
- Commits: 9 commits

Implementation approach:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [x] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
- Add time range to filter total count for payment attempt list.
- Move `TimeRange` type to common utils so that it can be used in diesel models and across all the other api models 

### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the datab
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** fix(payments): add time range in list payment attempts query (#5959)
Co-authored-by: hyperswitch-bot
Files to modify:


**crates/analytics/src/disputes/metrics.rs**
  Modify existing code

**crates/analytics/src/opensearch.rs**
  Modify existing code

**crates/api_models/src/analytics.rs**
  Modify existing code

**crates/api_models/src/analytics/search.rs**
  Modify existing code

**crates/api_models/src/events.rs**
  Remove:
    - impl: impl ApiEventMetric for TimeRange

**crates/api_models/src/payments.rs**
  Remove:
    - struct: pub::TimeRange

**crates/api_models/src/payouts.rs**
  Modify existing code

**crates/api_models/src/refunds.rs**
  Modify existing code

**crates/common_utils/src/events.rs**
  Add:
    - impl: impl ApiEventMetric for TimeRange

**crates/common_utils/src/types.rs**
  Add:
    - struct: pub::TimeRange

**crates/diesel_models/src/query/payment_attempt.rs**
  Modify existing code

**crates/hyperswitch_domain_models/src/payments/payment_attempt.rs**
  Modify existing code

**crates/hyperswitch_domain_models/src/payments/payment_intent.rs**
  Modify existing code

**crates/hyperswitch_domain_models/src/payouts.rs**
  Modify existing code

**crates/hyperswitch_domain_models/src/payouts/payouts.rs**
  Modify existing code

**crates/hyperswitch_domain_models/src/refunds.rs**
  Modify existing code

**crates/openapi/src/openapi.rs**
  Modify existing code

**crates/openapi/src/openapi_v2.rs**
  Modify existing code

**crates/router/src/core/disputes.rs**
  Modify existing code

**crates/router/src/core/payments.rs**
  Modify existing code

**crates/router/src/core/payouts.rs**
  Modify existing code

**crates/router/src/core/refunds.rs**
  Modify existing code

**crates/router/src/db/dispute.rs**
  Modify existing code

**crates/router/src/db/kafka_store.rs**
  Modify existing code

**crates/router/src/db/refund.rs**
  Modify existing code

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

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

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

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

**crates/router/src/types/api/payments.rs**
  Modify existing code

**crates/router/src/types/storage/dispute.rs**
  Modify existing code

**crates/router/src/types/storage/refund.rs**
  Modify existing code

**crates/storage_impl/src/mock_db/payment_attempt.rs**
  Modify existing code

**crates/storage_impl/src/mock_db/payment_intent.rs**
  Modify existing code

**crates/storage_impl/src/mock_db/payouts.rs**
  Modify existing code

**crates/storage_impl/src/payments/payment_attempt.rs**
  Modify existing code

**crates/storage_impl/src/payments/payment_intent.rs**
  Modify existing code

**crates/storage_impl/src/payouts/payouts.rs**
  Modify existing code