Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import: columns with numbers are not converted to string for importMapping lookups #2427

Open
5 tasks
sleidig opened this issue Jun 20, 2024 · 3 comments · May be fixed by #2823
Open
5 tasks

Import: columns with numbers are not converted to string for importMapping lookups #2427

sleidig opened this issue Jun 20, 2024 · 3 comments · May be fixed by #2823
Assignees

Comments

@sleidig
Copy link
Member

sleidig commented Jun 20, 2024

During imports a value is imported as number if it is all digits in the csv file. However, in our entities the related field may be a string. If such a field is used to map to an entity reference, the lookup in the EntityDatatype does not work anymore, as string and number equivalents of a value are not equal.

  • --> see EntityDatatype
  • update the method with better typing and jsDoc (copy below into the code)
  • write unit tests for its importMapFunction():
    • "should return/map to existing entity in DB if imported value matches the given field" (use mockEntityMapper() for mocking db)
      • ... variant of this where val is not exact match: imported is number but entity field is string (and vice versa)
    • "should return/map to undefined if value does not match with any existing entity in DB" (without errors)
  • implement logic for the above

details for EntityDatatype.importMapFunction:

  /**
   * Maps a value from an import to an actual entity in the database by comparing the value with the given field of entities.
   * @param val The value from an import that should be mapped to an entity reference
   * @param schemaField The config defining details of the field that will hold the entity reference after mapping (e.g. specifying the entity type that can be linked here)
   * @param additional The field of the referenced entity that should be compared with the val
   */
  async importMapFunction(
    val: any,
    schemaField: EntitySchemaField,
    additional?: string,
  )
@github-project-automation github-project-automation bot moved this to Triage / Analysis in All Tasks & Issues Jun 20, 2024
@sleidig sleidig moved this from Triage / Analysis to Todo (ready for work) in All Tasks & Issues Jun 21, 2024
@sleidig sleidig added the Status: Community Help Wanted (good first issue) simple tasks that don't require understanding every last detail of our platform label Jul 15, 2024
@kumarannathan
Copy link

kumarannathan commented Nov 7, 2024

Hi @sleidig!
I’m interested in working on this issue as part of my EECS 481 class: https://web.eecs.umich.edu/~weimerw/481/hw6.html.
I’d like to enhance importMapFunction by adding types, jsDocs, and relevant unit tests. Let me know if there’s any guidance you’d recommend. Thanks!

@sleidig
Copy link
Member Author

sleidig commented Nov 7, 2024

Hi @kumarannathan , thanks for reaching out and finding us! It's great to see your initiative to help our system - and thereby all our NGOs and social workers using Aam Digital 😃

Have you worked with Angular and TypeScript before and are familiar with unit tests written in jasmine? (sorry, many details!)

We'll be happy to guide you on the specifics of the Aam Digital code base and this concrete issue/task then.

@sleidig sleidig moved this from Todo (ready for work) to In Review in All Tasks & Issues Dec 9, 2024
@sleidig sleidig removed the Status: Community Help Wanted (good first issue) simple tasks that don't require understanding every last detail of our platform label Dec 9, 2024
@sleidig sleidig added the Status: Community Help Wanted (good first issue) simple tasks that don't require understanding every last detail of our platform label Dec 10, 2024
@sleidig sleidig moved this from In Review to In Progress in All Tasks & Issues Dec 10, 2024
@sleidig
Copy link
Member Author

sleidig commented Dec 10, 2024

Test Scenario: importing "Recurring Activity" records, including a Child to be linked in the "participants" field of the Recurring Activity that is created by the import.

The Child entity is identified by matching the "phone number" of a Child in the database with the "phone number" column in the imported sheet:

Steps to prepare & test:

  1. Open the app in demo mode with generated data
  2. Edit the Child "Udai Marar", setting the phone number field to "123"
  3. Go to "Import"
  4. Upload the sample file: import-numbers.csv
  5. Select "Recurring Activity" as import target type in step 2 of the import flow
  6. Map the imported column "name" -> select "Title"
  7. Map the imported column "userNumber" -> select "Participants"; Click "Configure value mapping" and select "Phone Number" as the matching field for the linking
  8. Continue to the "Review" step of the import flow
  9. --> check the results in the "Participants" column of the preview of data to be imported:
  • row one correctly links Child "Adikavi Malik" via the phone number
    • case where that number is clearly a string (with a "+" prefix); this already works now)
  • row two is not linking any Child
    • case where the number is a "number" only - this fails to look up the correct user entity during import (before this bugfix)

@sleidig sleidig removed the Status: Community Help Wanted (good first issue) simple tasks that don't require understanding every last detail of our platform label Jan 28, 2025
@sadaf895 sadaf895 linked a pull request Jan 29, 2025 that will close this issue
@sadaf895 sadaf895 moved this from In Progress to Technical Review in All Tasks & Issues Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Technical Review
Development

Successfully merging a pull request may close this issue.

3 participants