Commit 7118a5c5 authored by Michael Ott's avatar Michael Ott
Browse files

Perform fuzzy query if no start and end timestamp are given

parent f3c8edba
......@@ -45,7 +45,7 @@ void usage(void)
if (isatty(fileno(stdin))) {
/* 0---------1---------2---------3---------4---------5---------6---------7--------- */
std::cout << "Usage:" << std::endl;
std::cout << " dcdbquery [-h <host>] [-r] [-l] <Sensor 1> [<Sensor 2> ...] <Start> <End>" << std::endl;
std::cout << " dcdbquery [-h <host>] [-r] [-l] <Sensor 1> [<Sensor 2> ...] [<Start> <End>]" << std::endl;
std::cout << " dcdbquery [-h <host>] [-r] [-l] -j <jobId> <Sensor 1> [<Sensor 2> ...]" << std::endl;
std::cout << std::endl;
std::cout << "Parameters:" << std::endl;
......@@ -103,7 +103,7 @@ int main(int argc, char * const argv[])
}
/* Check command line arguments */
if (argcReal <= 3) {
if (argcReal <= 1) {
usage();
}
......@@ -142,25 +142,27 @@ int main(int argc, char * const argv[])
/* Try to create TimeStamp objects from the arguments */
DCDB::TimeStamp start, end;
if (jobId.size() == 0) {
try {
bool local = myQuery->getLocalTimeEnabled();
start = DCDB::TimeStamp(argvReal[argcReal-2], local);
if(std::string(argvReal[argcReal-2]) != std::string(argvReal[argcReal-1])) {
end = DCDB::TimeStamp(argvReal[argcReal - 1], local);
} else {
end = start;
}
} catch (std::exception& e) {
std::cout << "Wrong time format." << std::endl;
exit(EXIT_FAILURE);
if (argcReal > 2) {
try {
bool local = myQuery->getLocalTimeEnabled();
start = DCDB::TimeStamp(argvReal[argcReal-2], local);
if(std::string(argvReal[argcReal-2]) != std::string(argvReal[argcReal-1])) {
end = DCDB::TimeStamp(argvReal[argcReal - 1], local);
} else {
end = start;
}
argcReal-= 2;
} catch (std::exception& e) {
/* The last two parameters could not be parsed as timestamps, let's assume they are sensors and do a fuzzy querry */
start = end = DCDB::TimeStamp();
}
/* Ensure start < end */
if(start > end) {
std::cout << "Start time must be earlier than end time." << std::endl;
exit(EXIT_FAILURE);
}
}
/* Ensure start < end */
if(start > end) {
std::cout << "Start time must be earlier than end time." << std::endl;
exit(EXIT_FAILURE);
}
argcReal-= 2;
}
/* Build a list of sensornames */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment