async def get_cumulative_users(ns={}): if ns.get('target') == 'year': target_info = '%%Y' elif ns.get('target') == 'month': target_info = '%%Y-%%m' else: target_info = '%%Y-%%m-%%d' db = DBPools() async with db.sqlorContext('kboss') as sor: count_sql = """ SELECT MONTH as target, ( SELECT COUNT(*) FROM organization u2 WHERE DATE_FORMAT( u2.create_at, '%s' ) <= monthly_counts.MONTH AND parentid = 'mIWUHBeeDM8mwAFPIQ8pS' AND org_type IN ( 2, 3 ) AND del_flg = '0' ) AS cumulative_users FROM ( SELECT DISTINCT DATE_FORMAT( create_at, '%s' ) AS MONTH FROM organization ) AS monthly_counts ORDER BY MONTH;""" % (target_info, target_info) count_li = await sor.sqlExe(count_sql, {}) return { 'status': True, 'msg': '获取用户数量成功', 'data': count_li } ret = await get_cumulative_users(params_kw) return ret