跳至内容
菜单
此问题已终结
1576 查看

I have an API endpoint POST /database that is responsible for creating a new database. However, the current implementation seems to have performance issues, as it is slow. Here's the relevant code

router.py

@router.post("/", status_code=HTTP_201_CREATED)defcreate_env(data: Environment, env=Depends(master_env)):
    # Load the required models# Call the init() method on the module
    newEnv = env["api.env"].create(data.dict())
    return EnvironmentOutput.from_orm(newEnv)

model.py

@api.model

defcreate(self, vals): 

​vals.update({ "email": self.env.context["email"] })

​ env = super(Environment, self).create(vals) 

           ret = exp_create_database( vals["name"], False, False, user_password=vals["name"],                                                        login=vals["email"], country_code=None, phone=None

          registry = odoo.registry(vals["name"]).check_signaling()  

         with registry.manage_changes():

                  with registry.cursor() as cr: e = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})

                           m =  e["ir.module.module"].search([('name', '=', "api")], limit=1)   

                           m.button_immediate_install() return env

I'm looking for suggestions on how to optimize this code and improve its performance. Any ideas or best practices to handle this scenario more efficiently would be greatly appreciated.

形象
丢弃
相关帖文 回复 查看 活动
5
9月 25
22000
3
8月 25
3184
1
5月 25
3076
1
4月 25
4040
1
4月 25
4907