Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(global-search): dashboard globalsearch apis #3831

Merged
merged 34 commits into from
Mar 12, 2024

Conversation

ivor11
Copy link
Contributor

@ivor11 ivor11 commented Feb 26, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Search APIs for dashboard global search

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Search APIs for dashboard global search

How did you test it?

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

@ivor11 ivor11 requested review from a team as code owners February 26, 2024 20:52
@ivor11 ivor11 self-assigned this Feb 26, 2024
@ivor11 ivor11 changed the title Feat/global search feat(global search): dashboard globalsearch apis Feb 26, 2024
crates/router/src/analytics.rs Outdated Show resolved Hide resolved
crates/router/src/configs/settings.rs Outdated Show resolved Hide resolved
crates/api_models/src/analytics.rs Outdated Show resolved Hide resolved
crates/api_models/src/analytics/search.rs Outdated Show resolved Hide resolved
crates/router/src/analytics.rs Outdated Show resolved Hide resolved
crates/api_models/src/analytics.rs Outdated Show resolved Hide resolved
Comment on lines 105 to 107
let client = get_opensearch_client(url.to_owned())
.await
.map_err(|_| AnalyticsError::UnknownError)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add our own wrapper struct around the opensearch client?

such that it will accept all the domain new types & opensearch client specific things like generating a json request etc will be restricted to that client implementation...

this will also help us provide the opensearch index name from env,

can refer to the kafka implementation...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add this in the next PR

.body(json!({"query": {"bool": {"must": {"query_string": {"query": req.query}}, "filter": {"match_phrase": {"merchant_id": merchant_id}}}}}))
.send()
.await
.map_err(|_| AnalyticsError::UnknownError)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to add proper error variants here ig...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add this in the next PR with the wrapper struct

@ivor11
Copy link
Contributor Author

ivor11 commented Feb 28, 2024

curl --location --request POST 'http://localhost:8080/analytics/v1/search/payment_intents' \
--header 'api-key: hyperswitch' \
--header 'authorization: Bearer *' \
--header 'content-type: application/json' \
--data-raw '{
    "offset": 0,
    "count": 10,
    "query": "joseph"
}'
{"count":2,"index":"payment_intents","hits":[{"payment_id":"pay_sj8aVNPLFrctjkOF3UoT","merchant_id":"postman_merchant_GHAction_11f62d0d-df98-4b35-8629-a1eee1edfa92","status":"succeeded","amount":6540,"currency":"USD","amount_captured":6540,"customer_id":"StripeCustomer","description":"Its my first payment request","return_url":"https://duck.com/","connector_id":null,"statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","created_at":1709032037,"modified_at":1709032039,"last_synced":1709032037,"setup_future_usage":null,"off_session":null,"client_secret":"pay_sj8aVNPLFrctjkOF3UoT_secret_xKyu8zgVxB6K0lzVXqqq","active_attempt_id":"pay_sj8aVNPLFrctjkOF3UoT_1","business_country":null,"business_label":"default","attempt_count":1,"sign_flag":1},{"payment_id":"pay_4rcoPWbtWs1DghxR29Ur","merchant_id":"postman_merchant_GHAction_11f62d0d-df98-4b35-8629-a1eee1edfa92","status":"succeeded","amount":6540,"currency":"USD","amount_captured":6540,"customer_id":"StripeCustomer","description":"Its my first payment request","return_url":"https://duck.com/","connector_id":null,"statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","created_at":1709027992,"modified_at":1709027994,"last_synced":1709027992,"setup_future_usage":null,"off_session":null,"client_secret":"pay_4rcoPWbtWs1DghxR29Ur_secret_FbviEUdG7FNMf3S7socJ","active_attempt_id":"pay_4rcoPWbtWs1DghxR29Ur_1","business_country":null,"business_label":"default","attempt_count":1,"sign_flag":1}]```

@ivor11
Copy link
Contributor Author

ivor11 commented Feb 28, 2024

curl --location --request POST 'http://localhost:8080/analytics/v1/search' \                                                                                ✭
--header 'api-key: hyperswitch' \
--header 'authorization: Bearer *'  \
--header 'content-type: application/json' \
--data-raw '{
    "query": "joseph"
}'
[{"count":0,"index":"payment_attempts","hits":[]},{"count":2,"index":"payment_intents","hits":[{"payment_id":"pay_sj8aVNPLFrctjkOF3UoT","merchant_id":"postman_merchant_GHAction_11f62d0d-df98-4b35-8629-a1eee1edfa92","status":"succeeded","amount":6540,"currency":"USD","amount_captured":6540,"customer_id":"StripeCustomer","description":"Its my first payment request","return_url":"https://duck.com/","connector_id":null,"statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","created_at":1709032037,"modified_at":1709032039,"last_synced":1709032037,"setup_future_usage":null,"off_session":null,"client_secret":"pay_sj8aVNPLFrctjkOF3UoT_secret_xKyu8zgVxB6K0lzVXqqq","active_attempt_id":"pay_sj8aVNPLFrctjkOF3UoT_1","business_country":null,"business_label":"default","attempt_count":1,"sign_flag":1},{"payment_id":"pay_4rcoPWbtWs1DghxR29Ur","merchant_id":"postman_merchant_GHAction_11f62d0d-df98-4b35-8629-a1eee1edfa92","status":"succeeded","amount":6540,"currency":"USD","amount_captured":6540,"customer_id":"StripeCustomer","description":"Its my first payment request","return_url":"https://duck.com/","connector_id":null,"statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","created_at":1709027992,"modified_at":1709027994,"last_synced":1709027992,"setup_future_usage":null,"off_session":null,"client_secret":"pay_4rcoPWbtWs1DghxR29Ur_secret_FbviEUdG7FNMf3S7socJ","active_attempt_id":"pay_4rcoPWbtWs1DghxR29Ur_1","business_country":null,"business_label":"default","attempt_count":1,"sign_flag":1}]},{"count":0,"index":"refunds","hits":[]}]

@ivor11 ivor11 linked an issue Feb 28, 2024 that may be closed by this pull request
@ivor11 ivor11 changed the title feat(global search): dashboard globalsearch apis feat(global-search): dashboard globalsearch apis Mar 1, 2024
sagarnaikjuspay
sagarnaikjuspay previously approved these changes Mar 6, 2024
@Gnanasundari24 Gnanasundari24 enabled auto-merge March 6, 2024 11:43
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Mar 12, 2024
Merged via the queue into main with commit ac8ddd4 Mar 12, 2024
10 of 12 checks passed
@Gnanasundari24 Gnanasundari24 deleted the feat/global-search branch March 12, 2024 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GlobalSearch] - API support for free form text search
5 participants