mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +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,
|
||||
data_keys: Vec<enums::DashboardMetadata>,
|
||||
) -> 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(
|
||||
&conn,
|
||||
user_id.to_owned(),
|
||||
@ -118,7 +118,7 @@ impl DashboardMetadataInterface for Store {
|
||||
org_id: &id_type::OrganizationId,
|
||||
data_keys: Vec<enums::DashboardMetadata>,
|
||||
) -> 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(
|
||||
&conn,
|
||||
merchant_id.to_owned(),
|
||||
|
||||
@ -80,7 +80,7 @@ impl RoleInterface for Store {
|
||||
&self,
|
||||
role_id: &str,
|
||||
) -> 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)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
@ -93,7 +93,7 @@ impl RoleInterface for Store {
|
||||
merchant_id: &id_type::MerchantId,
|
||||
org_id: &id_type::OrganizationId,
|
||||
) -> 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)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
@ -105,7 +105,7 @@ impl RoleInterface for Store {
|
||||
role_id: &str,
|
||||
org_id: &id_type::OrganizationId,
|
||||
) -> 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)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
@ -140,7 +140,7 @@ impl RoleInterface for Store {
|
||||
merchant_id: &id_type::MerchantId,
|
||||
org_id: &id_type::OrganizationId,
|
||||
) -> 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)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
@ -154,7 +154,7 @@ impl RoleInterface for Store {
|
||||
entity_type: Option<enums::EntityType>,
|
||||
limit: Option<u32>,
|
||||
) -> 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(
|
||||
&conn,
|
||||
org_id.to_owned(),
|
||||
|
||||
@ -71,7 +71,7 @@ impl UserInterface for Store {
|
||||
&self,
|
||||
user_email: &pii::Email,
|
||||
) -> 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)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
@ -82,7 +82,7 @@ impl UserInterface for Store {
|
||||
&self,
|
||||
user_id: &str,
|
||||
) -> 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)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
@ -127,7 +127,7 @@ impl UserInterface for Store {
|
||||
&self,
|
||||
user_ids: Vec<String>,
|
||||
) -> 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)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
|
||||
@ -103,7 +103,7 @@ impl UserRoleInterface for Store {
|
||||
profile_id: Option<&id_type::ProfileId>,
|
||||
version: enums::UserRoleVersion,
|
||||
) -> 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(
|
||||
&conn,
|
||||
user_id.to_owned(),
|
||||
|
||||
Reference in New Issue
Block a user