Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Fix handling of numeric custom cells in Excel #1757

Merged
merged 1 commit into from Mar 21, 2022

Conversation

TaiWilkin
Copy link
Contributor

@TaiWilkin TaiWilkin commented Mar 21, 2022

Overview

Custom cells can have numeric values. When parsing the sheets, a value
that appears as 130 in the workbook can appear as a float 130.0.

This commit attempts to fix this issue by using an
int(float(x)) nested cast to ensure that the decimal portion is removed.

Note that this will convert all floats to integers when submitted as
custom text. If a contributor would like to submit floats in a custom
text field in the future, we will need to implement that as an
enhancement.

The handling of this was based on the recent fix for number_of_workers.

Connects #1748

Demo

Screen Shot 2022-03-21 at 10 17 46 AM

Testing Instructions

NOTE: Custom text indexing can take a minute to run, so wait after adjusting any searchable field.

On develop:

  • Run ./scripts/server
  • Submit
    Numeric_Custom_List.xlsx
  • Process the list using ./tools/batch_process {list_id}
  • Login as c2@example.com and navigate to the settings -> embed, then set a width and height so your map preview displays
  • Select custom_field as a searchable field.
  • Search for 23876. No results will return. Search for 23876.0 and one result should return.
  • Deselect custom_field as a searchable field.

On this branch:

  • Run ./scripts/server
  • Select custom_2 as a searchable field.
  • Search for 12345 and one result should return.
  • Select custom_field as searchable. Search for 23876 and one result should return.

Checklist

  • fixup! commits have been squashed
  • CI passes after rebase
  • CHANGELOG.md updated with summary of features or fixes, following Keep a Changelog guidelines

Copy link
Contributor

@rajadain rajadain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 tested, this is working well!

@@ -47,12 +47,19 @@ def get_csv_values(csv_data):
return values


def try_parse_float(value):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider naming this try_parse_int_from_float since that's what you're getting in the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Custom cells can have numeric values. When parsing the sheets, a value
that appears as 130 in the workbook can appear as a float 130.0.

This commit attempts to fix this issue by using an
int(float(x)) nested cast to ensure that the decimal portion is removed.

Note that this will convert all floats to integers when submitted as
custom text. If a contributor would like to submit floats in a custom
text field in the future, we will need to implement that as an
enhancement.
@TaiWilkin TaiWilkin merged commit 7c769fc into develop Mar 21, 2022
@TaiWilkin TaiWilkin deleted the tw/numeric-custom-fields branch March 21, 2022 16:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants