@@ -1091,12 +1091,13 @@ func (impl UserAuthRepositoryImpl) GetRoleForOtherEntity(team, app, env, act, ac
1091
1091
var queryParams []interface {}
1092
1092
query := "SELECT role.* FROM roles role WHERE role.team = ? AND role.entity_name=? AND role.environment=? AND role.action=?"
1093
1093
queryParams = append (queryParams , team , app , env , act )
1094
- if oldValues {
1095
- query = query + " and role.access_type is NULL"
1096
- } else {
1097
- query += " and role.access_type = ? "
1098
- queryParams = append (queryParams , accessType )
1099
- }
1094
+ // Both branches were identical; refactored for clarity and maintainability
1095
+ if oldValues {
1096
+ query += " and role.access_type is NULL"
1097
+ } else {
1098
+ query += " and role.access_type = ? "
1099
+ queryParams = append (queryParams , accessType )
1100
+ }
1100
1101
1101
1102
_ , err = impl .dbConnection .Query (& model , query , queryParams ... )
1102
1103
} else if len (team ) > 0 && app == "" && len (env ) > 0 && len (act ) > 0 {
@@ -1127,15 +1128,14 @@ func (impl UserAuthRepositoryImpl) GetRoleForOtherEntity(team, app, env, act, ac
1127
1128
var queryParams []interface {}
1128
1129
//this is applicable for all environment of a team
1129
1130
query := "SELECT role.* FROM roles role WHERE role.team = ? AND coalesce(role.entity_name,'')=? AND coalesce(role.environment,'')=? AND role.action=?"
1130
- queryParams = append (queryParams , team , EMPTY_PLACEHOLDER_FOR_QUERY , EMPTY_PLACEHOLDER_FOR_QUERY , act )
1131
- if oldValues {
1132
- query = query + " and role.access_type is NULL"
1133
- } else {
1134
- query += " and role.access_type = ? "
1135
- queryParams = append (queryParams , accessType )
1136
- }
1137
-
1138
- _ , err = impl .dbConnection .Query (& model , query , queryParams ... )
1131
+ queryParams = append (queryParams , team , EMPTY_PLACEHOLDER_FOR_QUERY , EMPTY_PLACEHOLDER_FOR_QUERY , act )
1132
+ if oldValues {
1133
+ query = query + " and role.access_type is NULL"
1134
+ } else {
1135
+ query += " and role.access_type = ? "
1136
+ queryParams = append (queryParams , accessType )
1137
+ }
1138
+ _ , err = impl .dbConnection .Query (& model , query , queryParams ... )
1139
1139
} else if team == "" && app == "" && env == "" && len (act ) > 0 {
1140
1140
var queryParams []interface {}
1141
1141
//this is applicable for super admin, all env, all team, all app
0 commit comments