validate: Generalized code to allow autoFill calls from other places

This commit is contained in:
Paul Beckingham 2016-07-24 09:08:10 -04:00
parent 45b09986d8
commit 1555847537

View file

@ -38,13 +38,10 @@
// range. // range.
// //
static void autoFill ( static void autoFill (
const CLI& cli,
const Rules& rules, const Rules& rules,
Database& database, Database& database,
const Interval& filter, const Interval& filter,
Interval& interval) Interval& interval)
{
if (findHint (cli, ":fill"))
{ {
// An empty filter allows scanning beyond interval.range. // An empty filter allows scanning beyond interval.range.
Interval range_filter; Interval range_filter;
@ -76,7 +73,6 @@ static void autoFill (
} }
} }
} }
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// :adjust // :adjust
@ -86,13 +82,12 @@ static void autoFill (
// recorded data. // recorded data.
// //
static void autoAdjust ( static void autoAdjust (
const CLI& cli, bool adjust,
const Rules& rules, const Rules& rules,
Database& database, Database& database,
Interval& interval) Interval& interval)
{ {
// Without :adjust, overlapping intervals are an error condition. // Without (adjust == true), overlapping intervals are an error condition.
auto adjust = findHint (cli, ":adjust");
// An empty filter allows scanning beyond interval.range. // An empty filter allows scanning beyond interval.range.
Interval range_filter; Interval range_filter;
@ -150,7 +145,6 @@ static void autoAdjust (
*/ */
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -194,8 +188,10 @@ void validate (
filter.range = Range (Datetime ("today"), Datetime ("tomorrow")); filter.range = Range (Datetime ("today"), Datetime ("tomorrow"));
// All validation performed here. // All validation performed here.
autoFill (cli, rules, database, filter, interval); if (findHint (cli, ":fill"))
autoAdjust (cli, rules, database, interval); autoFill (rules, database, filter, interval);
autoAdjust (findHint (cli, ":adjust"), rules, database, interval);
// TODO This warning is not working properly, because when an interval is // TODO This warning is not working properly, because when an interval is
// modified, it ifirst deleted, then added. This causes this code to // modified, it ifirst deleted, then added. This causes this code to