MCPcopy
hub / github.com/daptin/daptin / GetConfigIntValueFor

Method GetConfigIntValueFor

server/resource/cms_config.go:246–275  ·  view source on GitHub ↗
(key string, configtype string, transaction *sqlx.Tx)

Source from the content-addressed store, hash-verified

244}
245
246func (configStore *ConfigStore) GetConfigIntValueFor(key string, configtype string, transaction *sqlx.Tx) (int, error) {
247 var val int
248
249 s, v, err := statementbuilder.Squirrel.Select("value").Prepared(true).
250 From(settingsTableName).
251 Where(goqu.Ex{"name": key}).
252 Where(goqu.Ex{"configstate": "enabled"}).
253 Where(goqu.Ex{"configenv": configStore.defaultEnv}).
254 Where(goqu.Ex{"configtype": configtype}).ToSQL()
255
256 CheckErr(err, "Failed to create config select query")
257
258 stmt1, err := transaction.Preparex(s)
259 if err != nil {
260 log.Errorf("[209] failed to prepare statment: %v", err)
261 return 0, err
262 }
263 defer func(stmt1 *sqlx.Stmt) {
264 err := stmt1.Close()
265 if err != nil {
266 log.Errorf("failed to close prepared statement: %v", err)
267 }
268 }(stmt1)
269
270 err = stmt1.QueryRowx(v...).Scan(&val)
271 if err != nil {
272 log.Printf("[278] No config value set for [%v]: %v", key, err)
273 }
274 return val, err
275}
276
277func (configStore *ConfigStore) GetAllConfig(transaction *sqlx.Tx) map[string]string {
278

Calls 6

ScanMethod · 0.80
QueryRowxMethod · 0.80
CheckErrFunction · 0.70
SelectMethod · 0.65
PreparexMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected