mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
refactor(users): Update Database connection for Read only functions (#6167)
This commit is contained in:
@ -99,7 +99,7 @@ impl DashboardMetadataInterface for Store {
|
|||||||
org_id: &id_type::OrganizationId,
|
org_id: &id_type::OrganizationId,
|
||||||
data_keys: Vec<enums::DashboardMetadata>,
|
data_keys: Vec<enums::DashboardMetadata>,
|
||||||
) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> {
|
) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> {
|
||||||
let conn = connection::pg_connection_write(self).await?;
|
let conn = connection::pg_connection_read(self).await?;
|
||||||
storage::DashboardMetadata::find_user_scoped_dashboard_metadata(
|
storage::DashboardMetadata::find_user_scoped_dashboard_metadata(
|
||||||
&conn,
|
&conn,
|
||||||
user_id.to_owned(),
|
user_id.to_owned(),
|
||||||
@ -118,7 +118,7 @@ impl DashboardMetadataInterface for Store {
|
|||||||
org_id: &id_type::OrganizationId,
|
org_id: &id_type::OrganizationId,
|
||||||
data_keys: Vec<enums::DashboardMetadata>,
|
data_keys: Vec<enums::DashboardMetadata>,
|
||||||
) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> {
|
) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> {
|
||||||
let conn = connection::pg_connection_write(self).await?;
|
let conn = connection::pg_connection_read(self).await?;
|
||||||
storage::DashboardMetadata::find_merchant_scoped_dashboard_metadata(
|
storage::DashboardMetadata::find_merchant_scoped_dashboard_metadata(
|
||||||
&conn,
|
&conn,
|
||||||
merchant_id.to_owned(),
|
merchant_id.to_owned(),
|
||||||
|
|||||||
@ -80,7 +80,7 @@ impl RoleInterface for Store {
|
|||||||
&self,
|
&self,
|
||||||
role_id: &str,
|
role_id: &str,
|
||||||
) -> CustomResult<storage::Role, errors::StorageError> {
|
) -> CustomResult<storage::Role, errors::StorageError> {
|
||||||
let conn = connection::pg_connection_write(self).await?;
|
let conn = connection::pg_connection_read(self).await?;
|
||||||
storage::Role::find_by_role_id(&conn, role_id)
|
storage::Role::find_by_role_id(&conn, role_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||||
@ -93,7 +93,7 @@ impl RoleInterface for Store {
|
|||||||
merchant_id: &id_type::MerchantId,
|
merchant_id: &id_type::MerchantId,
|
||||||
org_id: &id_type::OrganizationId,
|
org_id: &id_type::OrganizationId,
|
||||||
) -> CustomResult<storage::Role, errors::StorageError> {
|
) -> CustomResult<storage::Role, errors::StorageError> {
|
||||||
let conn = connection::pg_connection_write(self).await?;
|
let conn = connection::pg_connection_read(self).await?;
|
||||||
storage::Role::find_by_role_id_in_merchant_scope(&conn, role_id, merchant_id, org_id)
|
storage::Role::find_by_role_id_in_merchant_scope(&conn, role_id, merchant_id, org_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||||
@ -105,7 +105,7 @@ impl RoleInterface for Store {
|
|||||||
role_id: &str,
|
role_id: &str,
|
||||||
org_id: &id_type::OrganizationId,
|
org_id: &id_type::OrganizationId,
|
||||||
) -> CustomResult<storage::Role, errors::StorageError> {
|
) -> CustomResult<storage::Role, errors::StorageError> {
|
||||||
let conn = connection::pg_connection_write(self).await?;
|
let conn = connection::pg_connection_read(self).await?;
|
||||||
storage::Role::find_by_role_id_in_org_scope(&conn, role_id, org_id)
|
storage::Role::find_by_role_id_in_org_scope(&conn, role_id, org_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||||
@ -140,7 +140,7 @@ impl RoleInterface for Store {
|
|||||||
merchant_id: &id_type::MerchantId,
|
merchant_id: &id_type::MerchantId,
|
||||||
org_id: &id_type::OrganizationId,
|
org_id: &id_type::OrganizationId,
|
||||||
) -> CustomResult<Vec<storage::Role>, errors::StorageError> {
|
) -> CustomResult<Vec<storage::Role>, errors::StorageError> {
|
||||||
let conn = connection::pg_connection_write(self).await?;
|
let conn = connection::pg_connection_read(self).await?;
|
||||||
storage::Role::list_roles(&conn, merchant_id, org_id)
|
storage::Role::list_roles(&conn, merchant_id, org_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||||
@ -154,7 +154,7 @@ impl RoleInterface for Store {
|
|||||||
entity_type: Option<enums::EntityType>,
|
entity_type: Option<enums::EntityType>,
|
||||||
limit: Option<u32>,
|
limit: Option<u32>,
|
||||||
) -> CustomResult<Vec<storage::Role>, errors::StorageError> {
|
) -> CustomResult<Vec<storage::Role>, errors::StorageError> {
|
||||||
let conn = connection::pg_connection_write(self).await?;
|
let conn = connection::pg_connection_read(self).await?;
|
||||||
storage::Role::generic_roles_list_for_org(
|
storage::Role::generic_roles_list_for_org(
|
||||||
&conn,
|
&conn,
|
||||||
org_id.to_owned(),
|
org_id.to_owned(),
|
||||||
|
|||||||
@ -71,7 +71,7 @@ impl UserInterface for Store {
|
|||||||
&self,
|
&self,
|
||||||
user_email: &pii::Email,
|
user_email: &pii::Email,
|
||||||
) -> CustomResult<storage::User, errors::StorageError> {
|
) -> CustomResult<storage::User, errors::StorageError> {
|
||||||
let conn = connection::pg_connection_write(self).await?;
|
let conn = connection::pg_connection_read(self).await?;
|
||||||
storage::User::find_by_user_email(&conn, user_email)
|
storage::User::find_by_user_email(&conn, user_email)
|
||||||
.await
|
.await
|
||||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||||
@ -82,7 +82,7 @@ impl UserInterface for Store {
|
|||||||
&self,
|
&self,
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
) -> CustomResult<storage::User, errors::StorageError> {
|
) -> CustomResult<storage::User, errors::StorageError> {
|
||||||
let conn = connection::pg_connection_write(self).await?;
|
let conn = connection::pg_connection_read(self).await?;
|
||||||
storage::User::find_by_user_id(&conn, user_id)
|
storage::User::find_by_user_id(&conn, user_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||||
@ -127,7 +127,7 @@ impl UserInterface for Store {
|
|||||||
&self,
|
&self,
|
||||||
user_ids: Vec<String>,
|
user_ids: Vec<String>,
|
||||||
) -> CustomResult<Vec<storage::User>, errors::StorageError> {
|
) -> CustomResult<Vec<storage::User>, errors::StorageError> {
|
||||||
let conn = connection::pg_connection_write(self).await?;
|
let conn = connection::pg_connection_read(self).await?;
|
||||||
storage::User::find_users_by_user_ids(&conn, user_ids)
|
storage::User::find_users_by_user_ids(&conn, user_ids)
|
||||||
.await
|
.await
|
||||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||||
|
|||||||
@ -103,7 +103,7 @@ impl UserRoleInterface for Store {
|
|||||||
profile_id: Option<&id_type::ProfileId>,
|
profile_id: Option<&id_type::ProfileId>,
|
||||||
version: enums::UserRoleVersion,
|
version: enums::UserRoleVersion,
|
||||||
) -> CustomResult<storage::UserRole, errors::StorageError> {
|
) -> CustomResult<storage::UserRole, errors::StorageError> {
|
||||||
let conn = connection::pg_connection_write(self).await?;
|
let conn = connection::pg_connection_read(self).await?;
|
||||||
storage::UserRole::find_by_user_id_org_id_merchant_id_profile_id(
|
storage::UserRole::find_by_user_id_org_id_merchant_id_profile_id(
|
||||||
&conn,
|
&conn,
|
||||||
user_id.to_owned(),
|
user_id.to_owned(),
|
||||||
|
|||||||
Reference in New Issue
Block a user