mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Added postprocess(processor, filter) function to formulas
to run an specific Data Processor, even if not configured to run automatically on import, over existing activities which pass the filter expression using configured parameters. Fixes #2037
This commit is contained in:
@@ -75,6 +75,7 @@ daterange(stop)
|
||||
|
||||
DATA PROCESSOR FUNCTIONS
|
||||
autoprocess(filter)
|
||||
postprocess(processor, filter)
|
||||
|
||||
RIDE SAMPLE DATA
|
||||
|
||||
|
||||
@@ -107,8 +107,9 @@ static struct {
|
||||
// print to qDebug for debugging
|
||||
{ "print", 1 }, // print(..) to qDebug for debugging
|
||||
|
||||
// autoprocess to run automatic data processors
|
||||
{ "autoprocess", 1 }, // autoprocess(filter)
|
||||
// Data Processor functions on filtered activiies
|
||||
{ "autoprocess", 1 }, // autoprocess(filter) to run auto data processors
|
||||
{ "postprocess", 2 }, // postprocess(processor, filter) to run processor
|
||||
|
||||
// add new ones above this line
|
||||
{ "", -1 }
|
||||
@@ -2369,7 +2370,7 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, RideItem *m, RideF
|
||||
|
||||
if (!f) return Result(0); // eek!
|
||||
|
||||
// now remove the override
|
||||
// now run auto data processors
|
||||
if (DataProcessorFactory::instance().autoProcess(f)) {
|
||||
// rideFile is now dirty!
|
||||
m->setDirty(true);
|
||||
@@ -2379,6 +2380,38 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, RideItem *m, RideF
|
||||
}
|
||||
break;
|
||||
|
||||
case 40 :
|
||||
{ // POSTPROCESS (processor, expression ) run processor
|
||||
Result returning(0);
|
||||
|
||||
if (leaf->fparms.count() < 2) return returning;
|
||||
else returning = eval(df, leaf->fparms[1], x, m, p, c);
|
||||
|
||||
if (returning.number) {
|
||||
|
||||
// processor we are running
|
||||
QString dp_name = *(leaf->fparms[0]->lvalue.n);
|
||||
|
||||
// lookup processor
|
||||
DataProcessor* dp = DataProcessorFactory::instance().getProcessors().value(dp_name, NULL);
|
||||
|
||||
if (!dp) return Result(0); // No such data processor
|
||||
|
||||
// ack ! we need to autoprocess, so open the ride
|
||||
RideFile *f = m->ride();
|
||||
|
||||
if (!f) return Result(0); // eek!
|
||||
|
||||
// now run the data processor
|
||||
if (dp->postProcess(f)) {
|
||||
// rideFile is now dirty!
|
||||
m->setDirty(true);
|
||||
}
|
||||
}
|
||||
return returning;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return Result(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user