mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-16 01:19:57 +00:00
Fix DataFilter regression
.. the daterange() commit broke almost every builtin function ! (it converted them to integers due to and if/else logic error. .. also tidied parser to separate literals and symbols whilst making builtin functions expr elements to look more closely at precedence
This commit is contained in:
@@ -537,17 +537,20 @@ void Leaf::validateFilter(DataFilter *df, Leaf *leaf)
|
||||
leaf->inerror = true;
|
||||
}
|
||||
|
||||
if (leaf->function == "daterange" && !dateRangeValidSymbols.exactMatch(symbol)) {
|
||||
DataFiltererrors << QString(QObject::tr("invalid literal for daterange(): %1")).arg(symbol);
|
||||
leaf->inerror = true;
|
||||
if (leaf->function == "daterange") {
|
||||
|
||||
} else {
|
||||
// convert to int days since using current date range config
|
||||
// should be able to get from parent somehow
|
||||
leaf->type = Leaf::Integer;
|
||||
if (symbol == "start") leaf->lvalue.i = QDate(1900,01,01).daysTo(df->context->currentDateRange().from);
|
||||
else if (symbol == "stop") leaf->lvalue.i = QDate(1900,01,01).daysTo(df->context->currentDateRange().to);
|
||||
else leaf->lvalue.i = 0;
|
||||
if (!dateRangeValidSymbols.exactMatch(symbol)) {
|
||||
DataFiltererrors << QString(QObject::tr("invalid literal for daterange(): %1")).arg(symbol);
|
||||
leaf->inerror = true;
|
||||
|
||||
} else {
|
||||
// convert to int days since using current date range config
|
||||
// should be able to get from parent somehow
|
||||
leaf->type = Leaf::Integer;
|
||||
if (symbol == "start") leaf->lvalue.i = QDate(1900,01,01).daysTo(df->context->currentDateRange().from);
|
||||
else if (symbol == "stop") leaf->lvalue.i = QDate(1900,01,01).daysTo(df->context->currentDateRange().to);
|
||||
else leaf->lvalue.i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (leaf->function == "config" && !configValidSymbols.exactMatch(symbol)) {
|
||||
|
||||
Reference in New Issue
Block a user