İçereği Atla
Menü
Bu soru işaretlendi
1535 Görünümler

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.

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
5
Eyl 25
21372
3
Ağu 25
3066
1
May 25
2948
1
Nis 25
3931
1
Nis 25
4787