Closed aminahbl closed 6 months ago
I can see if I can make these endpoints work in the backend.
@aminahbl ... would an output like this work for you?
{
"dn4:1.0": [
{
"display_name": "Kūṭadanta Sutta",
"file_name": "dn5",
"category": "dn",
"segmentnr": "dn5:1.1-1.2"
}
],
"dn4:1.1": [
{
"display_name": "Kūṭadanta Sutta",
"file_name": "dn5",
"category": "dn",
"segmentnr": "dn5:1.1-1.2"
},
{
"display_name": "Sāleyyaka Sutta",
"file_name": "mn41",
"category": "mn",
"segmentnr": "mn41:1.2"
},
{
"display_name": "Gopālaka Sutta",
"file_name": "ud4.3",
"category": "ud",
"segmentnr": "ud4.3:1.2"
},
{
"display_name": "Sela Sutta",
"file_name": "mn92",
"category": "mn",
"segmentnr": "mn92:1.2"
}
],
"dn4:1.2": [
{
"display_name": "Kūṭadanta Sutta",
"file_name": "dn5",
"category": "dn",
"segmentnr": "dn5:1.1-1.2"
},
{
"display_name": "Sāleyyaka Sutta",
"file_name": "mn41",
"category": "mn",
"segmentnr": "mn41:1.2"
},
{
"display_name": "Gopālaka Sutta",
"file_name": "ud4.3",
"category": "ud",
"segmentnr": "ud4.3:1.2"
},
{
"display_name": "Sela Sutta",
"file_name": "mn92",
"category": "mn",
"segmentnr": "mn92:1.2"
}
]
}
Having the filename for the root segment seemed a bit superfluous because you ask it to get the numbers for that specific filename.
Then next to that I made a collections query that just returns all the collections for that language. If that is too much (as some collections might be empty), I can also add a list of the collections used per page so you can compare both of those and just use the ones that are needed. Then with the next page you can add both together.
I also made the number of entries per page to 500 (was 100). If this becomes too slow, let me know and I can change that.
The current numbers view return is an array of objects like this:
There are a few issues with this, among them:
parallels
prop contains unpredictable data requiring extra manipulation on the FE.Proposal
numbers-view/collections
Stable table headers can be created with a new
numbers-view/collections
endpoint. If:numbers-view/numbers
Match data will return an array of objects containing
segment
andparallels
props. Both will contain data necessary to build links to segment text (filename
andsegmentnr
) and parallel objects will also have acollection
prop so the parallel can be linked to the correct table column, and adisplayname
prop for hover-over / focus element info.The endpoint will remain paged. To help calculate table size it will be helpful if a total item count is returned in the response. There is a FastAPI plugin (https://uriyyo-fastapi-pagination.netlify.app/tutorials/page-number-pagination/) that might make this relatively straightforward, but if returning a total is overly complicated, an alternative solution can be sought.