Add in new class to analyze records for automation of data.

This commit is contained in:
2020-07-28 17:39:13 -04:00
parent 51d3945c0b
commit b7e20e3302
3 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2020 <Kevin Whitakerr> <eyecreate@eyecreate.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "recordanalytics.h"
#include <QtConcurrent/QtConcurrent>
#include <QSqlQuery>
#include <QSqlRecord>
RecordAnalytics::RecordAnalytics(QObject* parent, QSqlDatabase db) : _db(db)
{
}
void RecordAnalytics::checkOilChangeNeededForVehicle(int vehicleId, int milesForChange, int monthsForChange)
{
QtConcurrent::run([&](){
QSqlQuery query = _db.exec("SELECT * FROM records WHERE records.servicetype = 0;");
int milesRecord = query.record().indexOf("miles");
int dateRecord = query.record().indexOf("servicedate");
while(query.next()) {
//TODO: query.value(milesRecord);
}
emit this->isOilChangeNeeded(false);
});
}