Tangerine-Community / Tangerine

Digitize your offline data collection. Create your Forms online with Tangerine Editor, conduct them offline with the Tangerine Android App. All results you collect can be exported as a CSV file, easy for processing in a spreadsheet. Tangerine has been used in over 1 million assessments and surveys in over 60 countries and in 100 languages.
http://www.tangerinecentral.org/
GNU General Public License v3.0
48 stars 30 forks source link

Visits tab is broken when Location ID contains a "-" #3628

Closed lachko closed 1 month ago

lachko commented 9 months ago

In the code here: https://github.com/Tangerine-Community/Tangerine/blob/8cf99749364ce63f1654a728465c2e218a53e46a/client/src/app/case-management/_services/case-management.service.ts#L34 we are asking for a specifc position in the string but if the string is '12-03-0010-45-5-9-2023' the date part of it is not extracted correclty. The same happens here: https://github.com/Tangerine-Community/Tangerine/blob/8cf99749364ce63f1654a728465c2e218a53e46a/client/src/app/case-management/_services/case-management.service.ts#L62

We should be using a differnet method to locate the date which is the last part of this string becuase split on a "-" will always be incorrect when the Location id contains a "-" For example something like: const regex = /(\d{1,2}-\d{1,2}-\d{4})$/; // Regular expression to match the date pattern

const match = visitKey.match(regex); // Attempt to find a match const extractedPart = match[1];

lachko commented 9 months ago

This is the effect Undefined-45 which you can never access becuase it is not list in forms.

Screenshot 2023-10-05 at 12 23 57

Another effect is that the location is not shown in the listing and thefore forms for that location cannot be accessed ![Uploading Screenshot 2023-10-05 at 13.44.54.png…]()

lachko commented 7 months ago

You can use this list to test:

district , ward_id , ward , school_id , schoolname Distrcit1 , hJ-NuD-GqT ,1, eTe8-NK5D -, Free Roman School Distrcit1 , hJ-NuD-GqT ,1, neSw-vMS7 , Free Roman School Distrcit1 , hJ-NuD-GqT ,1, d48U-'129nAR , Free Roman School Distrcit1 , hJ-NuD-GqT ,1, qwy8sAFNCE , Free Pentecostal School Distrcit1 , hJ-NuD-GqT ,1, nk5FWdbtJt , Catholic School

esurface commented 6 months ago

@lachko ready for review. Released in v3.30.1