mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Database: Exclusions are back to being strings again
This commit is contained in:
parent
1aa72f99b6
commit
b29f458a7b
3 changed files with 18 additions and 14 deletions
|
@ -57,6 +57,11 @@ void Database::initialize (const std::string& location)
|
|||
{
|
||||
Datafile df;
|
||||
df.initialize (file);
|
||||
|
||||
// New files need the set of current exclusions.
|
||||
if (! File (file).exists ())
|
||||
df.setExclusions (_exclusion);
|
||||
|
||||
_files.push_back (df);
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +120,7 @@ void Database::clearExclusions ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Database::addExclusion (const Exclusion& exclusion)
|
||||
void Database::addExclusion (const std::string& exclusion)
|
||||
{
|
||||
_exclusions.push_back (exclusion);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include <Datafile.h>
|
||||
#include <Interval.h>
|
||||
#include <Exclusion.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
@ -45,7 +44,7 @@ public:
|
|||
std::vector <Interval> getAllIntervals ();
|
||||
|
||||
void clearExclusions ();
|
||||
void addExclusion (const Exclusion&);
|
||||
void addExclusion (const std::string&);
|
||||
void addInterval (const Interval&);
|
||||
void modifyInterval (const Interval&);
|
||||
|
||||
|
@ -55,9 +54,9 @@ private:
|
|||
std::string currentDataFile () const;
|
||||
|
||||
private:
|
||||
std::string _location {"~/.timewarrior/data"};
|
||||
std::vector <Datafile> _files {};
|
||||
std::vector <Exclusion> _exclusions {};
|
||||
std::string _location {"~/.timewarrior/data"};
|
||||
std::vector <Datafile> _files {};
|
||||
std::vector <std::string> _exclusions {};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
16
src/init.cpp
16
src/init.cpp
|
@ -161,14 +161,17 @@ void initializeDataAndRules (
|
|||
if (shinyNewDatabase)
|
||||
rules.set ("temp.shiny", 1);
|
||||
|
||||
// Provide the exclusions from configuration to the database. These are used
|
||||
// to seed new Diatafile objects.
|
||||
initializeDatabaseExclusions (database, rules);
|
||||
|
||||
// Initialize the database (no data read), but files are enumerated.
|
||||
database.initialize (data._data);
|
||||
|
||||
// Provide the exclusions from configuration to the database.
|
||||
initializeDatabaseExclusions (database, rules);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The exclusions are read from configuration as strings, and passed to the
|
||||
// database object as strings.
|
||||
void initializeDatabaseExclusions (Database& database, const Rules& rules)
|
||||
{
|
||||
database.clearExclusions ();
|
||||
|
@ -176,13 +179,10 @@ void initializeDatabaseExclusions (Database& database, const Rules& rules)
|
|||
for (auto& name : rules.all ("exclusions."))
|
||||
{
|
||||
name = lowerCase (name);
|
||||
Exclusion e;
|
||||
if (name.substr (0, 16) == "exclusions.days.")
|
||||
e.initialize ("exc day " + rules.get (name) + " " + name.substr (16));
|
||||
database.addExclusion ("exc day " + rules.get (name) + " " + name.substr (16));
|
||||
else
|
||||
e.initialize ("exc " + name.substr (11) + " " + rules.get (name));
|
||||
|
||||
database.addExclusion (e);
|
||||
database.addExclusion ("exc " + name.substr (11) + " " + rules.get (name));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue