avniproject / avni-server

Backend APIs for Avni
https://avniproject.org
GNU Affero General Public License v3.0
7 stars 25 forks source link

[Performance] POST /api/subject #785

Open mahalakshme opened 1 month ago

mahalakshme commented 1 month ago

Need:

POST and PATCH /api/subject appear in the top 5 in Newrelic consistently

Analysis:

2 things causing slowness:

AC:

What does it accept as of version 2:

{
  "External ID": "string",
  "Subject type": "Individual",
  "Address": "India, Uttarakhand",
  "Location ID": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "Date of birth": "2024-10-11",
  "Gender": "Male",
  "Registration date": "2024-10-11",
  "First name": "string",
  "Middle name": "string",
  "Last name": "string",
  "Registration location": {
    "X": 19.1253108,
    "Y": 74.7364501
  },
  "observations": {},
  "Profile picture": "string",
  "Voided": true
}

What it should accept as of version 3:

{
   "External ID": "string",
  "Subject type": "Individual",
  "Address": {
     "Country": "India",
     "State": "Uttarakhand"
   },
  "Location ID": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "Date of birth": "2024-10-11",
  "Gender": "Male",
  "Registration date": "2024-10-11",
  "First name": "string",
  "Middle name": "string",
  "Last name": "string",
  "Registration location": {
    "X": 19.1253108,
    "Y": 74.7364501
  },
  "observations": {},
  "Profile picture": "string",
  "Voided": true
}

Tech inputs:

Out of scope:

Analysis notes:

How integration services uses Avni APIs:

Old: ignore

Questions:

Can we do this? Say the titleLineage is A,B,C Find id of C - if only one present then set individual to that id, else - mostly will end here itself Then find id of B, if only one present then set individual to addresses with title C and parent_id of B, else - Lets make child and parent combination unique and just do this - but there are 34 entries which have them same and 7k entries have , followed by space in the title Then find id of A, if only one present then id of B = title with B and ....

Inputs:

Inputs:

1t5j0y commented 6 days ago

Changes from AC:

mahalakshme commented 6 days ago

@1t5j0y Also suggest updating the swagger documentation.

1t5j0y commented 6 days ago

@mahalakshme already done.. anything missing?