FAI-CIVL / FAI-Airscore

AirScore - online paragliding / hanggliding GAP-based scoring software.
https://airscore.cc/
GNU General Public License v3.0
13 stars 17 forks source link

get_fsdb_info setting defaults that are not in the standard formula #233

Open kuaka opened 3 years ago

kuaka commented 3 years ago

get_fsdb_info is trying to read formula values from a fsdb file. When it does not find them it sometimes sets a default. It should be using what is already present in the formula object, which to my understanding was loaded from the formula file (e.g. gap2016.py etc). We should be keeping these defaults if the value is not present in the fsdb file. This was the cause of #227.

In the function I see that there are other "else" conditions and think that these should not be overiding what is already in the formula. If these are not present in the formula file then I think that they should be left as the formula object (should) have a default value anyway.

biuti commented 3 years ago

This should be fixed with https://github.com/FAI-CIVL/FAI-Airscore/commit/c9c82a0e150b13e6900af0f74a878f7f23842062.

kuaka commented 3 years ago

I still see some else statements that force a default. Any defaults should be the ones in the formula file (gap2016.py etc)

formula.formula_time = 'on' if fsdb_data.get('use_time_points') == '1' else 'off'

https://github.com/FAI-CIVL/FAI-Airscore/blob/d59591015673e58c005d97d228b79a1d9428c116/airscore/core/formula.py#L457

for example this sets time points to off if use_time_points is missing or not 1. It may never happen that this is missing in fsdb but that would be making an assumption. IMHO it would be better to code it something like this:

if fsdb_data.get('use_time_points') == '1' 
    formula.formula_time = 'on'

or

if fsdb_data.get('use_time_points') == '1':
   formula.formula_time = 'on'
elif  fsdb_data.get('use_time_points') == '0':
   formula.formula_time = 'off'

that way we are not overiding the default in the formula file in all other cases.

biuti commented 3 years ago

I left the binaries / fixed values always present, like formula_position. We can change but if FSDB format will change so much to be possibly missing or with different values, function would have to be rewritten anyway.