콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1570 화면

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