تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1567 أدوات العرض

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
سبتمبر 25
21916
3
أغسطس 25
3172
1
مايو 25
3063
1
أبريل 25
4028
1
أبريل 25
4893