Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-13147
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Nov 24, 2023
1 parent d85fb32 commit 3f60c5a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9
10
20 changes: 10 additions & 10 deletions src/storage/storage_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,11 @@ namespace OpenWifi {

std::string St{"SELECT SerialNumber FROM Devices WHERE SerialNumber=?"};

Select << ConvertParams(St), Poco::Data::Keywords::into(SerialNumber),
Poco::Data::Keywords::use(DeviceDetails.SerialNumber);
Select.execute();
// Select << ConvertParams(St), Poco::Data::Keywords::into(SerialNumber),
// Poco::Data::Keywords::use(DeviceDetails.SerialNumber);
// Select.execute();

if (Select.rowsExtracted() == 0) {
// if (Select.rowsExtracted() == 0) {
Config::Config Cfg(DeviceDetails.Configuration);
uint64_t Now = Utils::Now();

Expand All @@ -410,7 +410,7 @@ namespace OpenWifi {
Poco::Data::Statement Insert(Sess);

std::string St2{"INSERT INTO Devices ( " + DB_DeviceSelectFields + " ) " +
DB_DeviceInsertValues};
DB_DeviceInsertValues + " ON CONFLICT (SerialNumber) DO NOTHING"};

SetCurrentConfigurationID(DeviceDetails.SerialNumber, DeviceDetails.UUID);
DeviceRecordTuple R;
Expand All @@ -424,11 +424,11 @@ namespace OpenWifi {
poco_warning(Logger(), "Cannot create device: invalid configuration.");
return false;
}
} else {
poco_warning(Logger(), fmt::format("Device {} already exists.", SerialNumber));
return false;
}

// } else {
// poco_warning(Logger(), fmt::format("Device {} already exists.", SerialNumber));
// return false;
// }
return true;
} catch (const Poco::Exception &E) {
Logger().log(E);
}
Expand Down
3 changes: 3 additions & 0 deletions src/storage/storage_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ namespace OpenWifi {
Sess << "CREATE INDEX IF NOT EXISTS StatsSerial ON Statistics (SerialNumber ASC, "
"Recorded ASC)",
Poco::Data::Keywords::now;
Sess << "CREATE INDEX IF NOT EXISTS StatsSerial0 ON Statistics (SerialNumber ASC)",
Poco::Data::Keywords::now;
} else if (dbType_ == mysql) {
Sess << "CREATE TABLE IF NOT EXISTS Statistics ("
"SerialNumber VARCHAR(30), "
"UUID INTEGER, "
"Data TEXT, "
"Recorded BIGINT, "
"INDEX StatSerial0 (SerialNumber)), ",
"INDEX StatSerial (SerialNumber ASC, Recorded ASC))",
Poco::Data::Keywords::now;
}
Expand Down

0 comments on commit 3f60c5a

Please sign in to comment.