optimize tenant with saldo query
This commit is contained in:
30
api/additional_components.yaml
Normal file
30
api/additional_components.yaml
Normal file
@ -0,0 +1,30 @@
|
||||
# -------------------------------------------------------------------
|
||||
# ATTENTION: This file will not be parsed by Cheetah
|
||||
# Use plain openapi/yaml syntax, no Cheetah
|
||||
# escaping
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
tenant_with_saldo:
|
||||
description: tenant with saldo
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
salutation:
|
||||
type: string
|
||||
nullable: true
|
||||
firstname:
|
||||
type: string
|
||||
nullable: true
|
||||
lastname:
|
||||
type: string
|
||||
nullable: true
|
||||
address1:
|
||||
type: string
|
||||
nullable: true
|
||||
saldo:
|
||||
type: number
|
||||
nullable: true
|
||||
|
@ -72,4 +72,20 @@
|
||||
type: number
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
/v1/tenants/saldo:
|
||||
get:
|
||||
tags: [ "tenant", "account" ]
|
||||
summary: Return tenant with saldo of the account
|
||||
operationId: additional_methods.get_tenant_with_saldo
|
||||
responses:
|
||||
'200':
|
||||
description: get_tenant_with_saldo
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/tenant_with_saldo'
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
|
||||
|
@ -31,4 +31,16 @@ def get_account_saldo(user, token_info, accountId=None):
|
||||
"statement": "SELECT sum(amount) as saldo FROM account_entry_t WHERE account=%s",
|
||||
"params": (accountId, )
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
def get_tenant_with_saldo(user, token_info):
|
||||
return dbGetMany(user, token_info, {
|
||||
"statement": """
|
||||
SELECT t.firstname, t.lastname, t.address1, sum(a.amount) AS saldo
|
||||
FROM tenant_t t, account_entry_t a
|
||||
WHERE a.account = t.account
|
||||
GROUP BY t.firstname, t.lastname, t.address1
|
||||
""",
|
||||
"params": ()
|
||||
}
|
||||
)
|
||||
|
@ -1493,6 +1493,22 @@ paths:
|
||||
type: number
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
/v1/tenants/saldo:
|
||||
get:
|
||||
tags: [ "tenant", "account" ]
|
||||
summary: Return tenant with saldo of the account
|
||||
operationId: additional_methods.get_tenant_with_saldo
|
||||
responses:
|
||||
'200':
|
||||
description: get_tenant_with_saldo
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/tenant_with_saldo'
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
|
||||
|
||||
components:
|
||||
@ -1727,3 +1743,34 @@ components:
|
||||
type: integer
|
||||
note:
|
||||
type: string
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# ATTENTION: This file will not be parsed by Cheetah
|
||||
# Use plain openapi/yaml syntax, no Cheetah
|
||||
# escaping
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
tenant_with_saldo:
|
||||
description: tenant with saldo
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
salutation:
|
||||
type: string
|
||||
nullable: true
|
||||
firstname:
|
||||
type: string
|
||||
nullable: true
|
||||
lastname:
|
||||
type: string
|
||||
nullable: true
|
||||
address1:
|
||||
type: string
|
||||
nullable: true
|
||||
saldo:
|
||||
type: number
|
||||
nullable: true
|
||||
|
@ -156,3 +156,5 @@ components:
|
||||
#end if
|
||||
#end for
|
||||
#end for
|
||||
|
||||
#include raw "./api/additional_components.yaml"
|
||||
|
Reference in New Issue
Block a user