Skip to content

Commit 31622a4

Browse files
committed
refactoring
1 parent 7e7638c commit 31622a4

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

internal/sql/repository/deploymentConfig/repository.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,12 @@ func (impl *RepositoryImpl) UpdateAll(tx *pg.Tx, configs []*DeploymentConfig) ([
123123

124124
func (impl *RepositoryImpl) GetByAppIdAndEnvId(tx *pg.Tx, appId, envId int) (*DeploymentConfig, error) {
125125
result := &DeploymentConfig{}
126-
var query *orm.Query
127-
if tx != nil {
128-
query = tx.Model(result)
129-
} else {
130-
query = impl.dbConnection.Model(result)
126+
var connection orm.DB
127+
connection = tx
128+
if tx == nil {
129+
connection = impl.dbConnection
131130
}
132-
err := query.
131+
err := connection.Model(result).
133132
Join("INNER JOIN app a").
134133
JoinOn("deployment_config.app_id = a.id").
135134
Join("INNER JOIN environment e").
@@ -146,13 +145,12 @@ func (impl *RepositoryImpl) GetByAppIdAndEnvId(tx *pg.Tx, appId, envId int) (*De
146145

147146
func (impl *RepositoryImpl) GetAppLevelConfigForDevtronApps(tx *pg.Tx, appId int) (*DeploymentConfig, error) {
148147
result := &DeploymentConfig{}
149-
var query *orm.Query
150-
if tx != nil {
151-
query = tx.Model(result)
152-
} else {
153-
query = impl.dbConnection.Model(result)
148+
var connection orm.DB
149+
connection = tx
150+
if tx == nil {
151+
connection = impl.dbConnection
154152
}
155-
err := query.
153+
err := connection.Model(result).
156154
Join("INNER JOIN app a").
157155
JoinOn("deployment_config.app_id = a.id").
158156
Where("a.active = ?", true).

0 commit comments

Comments
 (0)