Skip to content

Commit dbd5b57

Browse files
committed
refactor(python): combine if-s
1 parent 43b7878 commit dbd5b57

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/templates/routes.py.ejs

+9-10
Original file line numberDiff line numberDiff line change
@@ -211,22 +211,21 @@ endpoints.forEach(function(endpoint) {
211211
let methodArgs
212212
let sql
213213
let formattedParams
214+
let model
214215
if (method.name === 'post' || method.name === 'put' || method.name === 'delete') {
215216
sql = convertToPsycopgNamedArguments(formatQueryForPython(method.query, 20))
216217
const params = extractParamsFromQuery(method.query)
217218
formattedParams = formatParamsAsPythonDict(params)
218-
}
219219
220-
let model
221-
if (method.name === 'post' || method.name === 'put') {
222-
const dto = query2dto(sqlParser, method)
223-
// LATER: do we really need signature and cache?
224-
model = obtainDtoName(dto)
225-
methodArgs = [ `body: ${model}`, ...argsFromPath, 'conn=Depends(db_connection)' ]
226-
}
220+
if (method.name === 'post' || method.name === 'put') {
221+
const dto = query2dto(sqlParser, method)
222+
// LATER: do we really need signature and cache?
223+
model = obtainDtoName(dto)
224+
methodArgs = [ `body: ${model}`, ...argsFromPath, 'conn=Depends(db_connection)' ]
227225
228-
if (method.name === 'delete') {
229-
methodArgs = [ ...argsFromPath, 'conn=Depends(db_connection)' ]
226+
} else if (method.name === 'delete') {
227+
methodArgs = [ ...argsFromPath, 'conn=Depends(db_connection)' ]
228+
}
230229
}
231230
232231
if (hasGetOne || hasGetMany) {

0 commit comments

Comments
 (0)