Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-13507
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Mar 15, 2024
1 parent 6595b37 commit 3a1011a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/StorageService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace OpenWifi {
ScriptDB_->Create();
ScriptDB_->Initialize();

FixDeviceTypeBug();

return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions src/StorageService.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ namespace OpenWifi {
bool AnalyzeCommands(Types::CountedMap &R);
bool AnalyzeDevices(GWObjects::Dashboard &D);

void FixDeviceTypeBug();

int Start() override;
void Stop() override;

Expand Down
21 changes: 21 additions & 0 deletions src/storage/storage_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,4 +1115,25 @@ namespace OpenWifi {
FieldList.push_back(field);
}

void Storage::FixDeviceTypeBug() {
try {
std::vector<std::string> ScriptLines{
"update devices set devicetype='ap' where devicetype='AP';",
"update devices set devicetype='switch' where devicetype='SWITCH';",
"update devices set devicetype='ap' where devicetype!='ap' and devicetype!='switch';"
};

for (const auto &ScriptLine : ScriptLines) {
try {
Poco::Data::Session Sess = Pool_->get();
Poco::Data::Statement SqlStatement(Sess);
SqlStatement << ScriptLine, Poco::Data::Keywords::now;
} catch (...) {
}
}
} catch (const Poco::Exception &E) {
Logger().log(E);
}
}

} // namespace OpenWifi

0 comments on commit 3a1011a

Please sign in to comment.