getodk / central

ODK Central is a server that is easy to use, very fast, and stuffed with features that make data collection easier. Contribute and make the world a better place! ✨🗄✨
https://docs.getodk.org/central-intro/
Apache License 2.0
125 stars 151 forks source link

itemsets.csv file generated during XLSForm conversion is not added to media #124

Closed lognaturel closed 4 years ago

lognaturel commented 4 years ago

One of the external data features, "fast external itemsets", involves generating a csv that goes alongside the form definition. Currently, this is not communicated back to Central.

Reproduce by:

  1. Uploading an XLSForm with a "fast external itemset" such as https://polio.github.io/elqas/assets/elqas_form_v1.xlsx
  2. Going to the media tab and seeing that the itemsets.csv file is requested

I believe that this is the only case of a file other than an XML form definition being generated by pyxform. Does that sound right, @yanokwa?

issa-tseng commented 4 years ago

so....... okay. first, we'll have to find a way for pyxform-http to communicate both binaries back. then i can deal with that payload.

yanokwa commented 4 years ago

itemsets.csv are the only other output that pyxform can currently generate and I'm bummed that I didn't catch it. One option is that I can stick the itemsets data into the payload under itemset(I'm open to a different name). It'd look like this...

{
  "error": null,
  "itemset": "\"list_name\",\"name\",\"label\",\"province\",\"district\"\n\"districts\",\"district_a\",\"District A (in Province 1)\",\"province_1\",\"\"\n\"districts\",\"district_b\",\"District B (in Province 1)\",\"province_1\",\"\"\n\"districts\",\"district_c\",\"District C (in Province 2)\",\"province_2\",\"\"\n\"\",\"\",\"\",\"\",\"\"\n\"lots\",\"lot_10\",\"Lot 10 (in District A)\",\"province_1\",\"district_a\"\n\"lots\",\"lot_20\",\"Lot 20 (in District A)\",\"province_1\",\"district_a\"\n\"lots\",\"lot_30\",\"Lot 30 (In District B)\",\"province_1\",\"district_b\"\n\"lots\",\"lot_40\",\"Lot 40 (In District C)\",\"province_2\",\"district_c\"\n",
  "result": "<?xml version=\"1.0\"?><h:html xmlns=\"http://www.w3.org/2002/xforms\" xmlns:h=\"http://www.w3.org/1999/xhtml\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:jr=\"http://openrosa.org/javarosa\" xmlns:orx=\"http://openrosa.org/xforms\" xmlns:odk=\"http://www.opendatakit.org/xforms\"><h:head><h:title>pyxform-clean</h:title><model><instance><pyxform-clean id=\"pyxform-clean\"><province/><district/><lot/><meta><instanceID/></meta></pyxform-clean></instance><bind nodeset=\"/pyxform-clean/province\" type=\"select1\"/><bind nodeset=\"/pyxform-clean/district\" type=\"string\"/><bind nodeset=\"/pyxform-clean/lot\" type=\"string\"/><bind nodeset=\"/pyxform-clean/meta/instanceID\" type=\"string\" readonly=\"true()\" jr:preload=\"uid\"/></model></h:head><h:body><select1 ref=\"/pyxform-clean/province\"><label>Province</label><item><label>Province 1</label><value>province_1</value></item><item><label>Province 2</label><value>province_2</value></item></select1><input ref=\"/pyxform-clean/district\" query=\"instance('districts')/root/item[province= /pyxform-clean/province ]\"><label>District</label></input><input ref=\"/pyxform-clean/lot\" query=\"instance('lots')/root/item[province= /pyxform-clean/province  and district= /pyxform-clean/district ]\"><label>Lot</label></input></h:body></h:html>",
  "status": 200,
  "warnings": []
}

@issa-tseng Would something like the above work for you? Note that those CSVs could be pretty big.

@lognaturel Can you imagine a future where we have other things being returned by pyxform? If so, then maybe we should change result to return a dict of objects (e.g., form-xml, itemsets-csv).

lognaturel commented 4 years ago

into the payload under itemset(I'm open to a different name)

Slightly pedantic but I'd vote for itemsets to match the filename.

Can you imagine a future where we have other things being returned by pyxform?

My crystal ball is a little fuzzy. I think we should proceed with this for now. We certainly don't have any current plans to generate other files.

issa-tseng commented 4 years ago

backend is merged. central will merge with 0.8 release. closing.