Conversation
…t creation working
Blank/unfilled tdes field is coming back as null string not None. Don't ask for orbits when no querying for specific object as this isn't allowed in the Scout API Add custom table template for Scout results.
…rvices). Change BaseDataService->DataService from upstream changes
Save a copy of input form parameters so we can do the NEO score filtering (and other filters in future). Check for expected signature. Add get_additional_context_data() for a few extra things for the template. Update template to show total number of results and no. filtered from (if applicable)
…ing of result numbers in template
…certainty. Add CA distance into results table.
|
| # print(result['neoScore'] >= neo_score_min, result['phaScore'] >= pha_score_min, \ | ||
| # result['geocentricScore'] < geo_score_max, ((result['rating'] is not None and \ | ||
| # impact_rating_min is not None and result['rating'] >= impact_rating_min) or \ | ||
| # impact_rating_min is None), (ca_dist_min is None or (ca_dist_min is not None and result['caDist'] is not None and\ |
There was a problem hiding this comment.
Lint: For readability, we restrict individual lines to 120 characters. This line is too long, and should be truncated somewhere. (or just removed if this code isn't needed.)
There was a problem hiding this comment.
This is currently needed due to the hard-to-test mess that is the later if- clause to end all if-clauses, as you so correctly note next... 🙃
| # float(result['caDist']) <= ca_dist_min)), pos_unc >= pos_unc_min , pos_unc <= pos_unc_max) | ||
| if result['neoScore'] >= neo_score_min and result['phaScore'] >= pha_score_min and \ | ||
| result['geocentricScore'] < geo_score_max and ((result['rating'] is not None and | ||
| impact_rating_min is not None and result['rating'] >= impact_rating_min) or |
There was a problem hiding this comment.
Lint: Replace this with something like:
if result['neoScore'] >= neo_score_min and result['phaScore'] >= pha_score_min and \
result['geocentricScore'] < geo_score_max and \
((result['rating'] is not None and
impact_rating_min is not None and
result['rating'] >= impact_rating_min
) or
impact_rating_min is None) and \
(ca_dist_min is None or
(ca_dist_min is not None and ca_dist is not None and ca_dist <= ca_dist_min)) and \
pos_unc >= pos_unc_min and pos_unc <= pos_unc_max:
This maintains the proper indentation for line overflows with all of the parentheticals, and is a little easier to read. Realistically though, this is an awful if statement and I don't really know what we are filtering on. It feels like we should pull this out into a test function where we can step through each of these logic conditions and understand them individually and in context...
There was a problem hiding this comment.
Oh I agree and an incorrect logic condition has already bitten me twice... I think the best plan is to:
- Apply your fixes to stop
lintyelling - Add some test coverage, possibly by pulling this code into a method like a
is_valid_target()which (lots) of variousresultdictionary combos can be thrown at - Potentially refactor this into a
Table/QTableand iterate over the various conditions making and applying row/bitmasks
This (draft) PR creates an interface to the JPL Scout service via its API endpoint. This is implemented using the new(ish)
tom_dataservices. It is substantially functional in terms of fetching, filtering and creating targets but some questions before it's mergeable:requests-based functionality, it's not clear how best to test this without hitting live servicesrequestto add a message to through the Djangomessagesinfrastructure, if e.g. the user searches for a target that is removedTargets can be created in the initial run of fetching targets but will need to be updated with new values for existingTargets if Scout reruns on the same data producing different results or the number of observations changes. I think generallyTargets in the TOM Toolkit once created are relatively static and only checking on thenameis done to avoid creating duplicates. I could sub-class thematch_target()to match on things other thannamebut the NEOx experience has taught me that checking for changes in e.g. the floating point orbital elements can be tricky. Any thoughts on how to do robust updating of changing Targets?