Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-13268
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Jan 4, 2024
1 parent 6305e92 commit 15f3eaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/StorageService.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ namespace OpenWifi {
bool simulated);
bool CreateDevice(Poco::Data::Session &Sess, GWObjects::Device &DeviceDetails);

bool GetDevice(LockedDbSession &Session, std::string &SerialNumber, GWObjects::Device &);
bool GetDevice(Poco::Data::Session &Session, std::string &SerialNumber, GWObjects::Device &DeviceDetails);
bool GetDevice(std::string &SerialNumber, GWObjects::Device &);
bool GetDevice(LockedDbSession &Session, const std::string &SerialNumber, GWObjects::Device &);
bool GetDevice(Poco::Data::Session &Session, const std::string &SerialNumber, GWObjects::Device &DeviceDetails);
bool GetDevice(const std::string &SerialNumber, GWObjects::Device &);
bool GetDevices(uint64_t From, uint64_t HowMany, std::vector<GWObjects::Device> &Devices,
const std::string &orderBy = "");
// bool GetDevices(uint64_t From, uint64_t HowMany, const std::string & Select,
Expand Down
13 changes: 5 additions & 8 deletions src/storage/storage_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,17 +708,14 @@ namespace OpenWifi {
return false;
}

bool Storage::GetDevice(Poco::Data::Session &Session, std::string &SerialNumber, GWObjects::Device &DeviceDetails) {
bool Storage::GetDevice(Poco::Data::Session &Session, const std::string &SerialNumber, GWObjects::Device &DeviceDetails) {
try {
Poco::Data::Statement Select(Session);
std::string St{"SELECT " + DB_DeviceSelectFields +
" FROM Devices WHERE SerialNumber=?"};
std::string St = fmt::format("SELECT {} FROM Devices WHERE SerialNumber='{}'", DB_DeviceSelectFields, SerialNumber);

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

if (Select.rowsExtracted() == 0)
return false;
ConvertDeviceRecord(R, DeviceDetails);
Expand All @@ -729,7 +726,7 @@ namespace OpenWifi {
return false;
}

bool Storage::GetDevice(std::string &SerialNumber, GWObjects::Device &DeviceDetails) {
bool Storage::GetDevice(const std::string &SerialNumber, GWObjects::Device &DeviceDetails) {
try {
auto Sess = Pool_->get();
return GetDevice(Sess, SerialNumber, DeviceDetails);
Expand All @@ -739,7 +736,7 @@ namespace OpenWifi {
return false;
}

bool Storage::GetDevice(LockedDbSession &Session, std::string &SerialNumber, GWObjects::Device &DeviceDetails) {
bool Storage::GetDevice(LockedDbSession &Session, const std::string &SerialNumber, GWObjects::Device &DeviceDetails) {
try {
std::lock_guard Lock(Session.Mutex());
return GetDevice(Session.Session(), SerialNumber, DeviceDetails);
Expand Down

0 comments on commit 15f3eaa

Please sign in to comment.