Fixing dashboard + adding firmware age average.

This commit is contained in:
stephb9959
2021-08-12 08:37:41 -07:00
parent 9f34cfe5e6
commit 21310ebee4
6 changed files with 9 additions and 5 deletions

2
build
View File

@@ -1 +1 @@
17
19

View File

@@ -239,6 +239,8 @@ components:
$ref: '#/components/schemas/TagIntPairList'
usingLatest:
$ref: '#/components/schemas/TagIntPairList'
totalSecondsOld:
$ref: '#/components/schemas/TagIntPairList'
#########################################################################################
##

View File

@@ -220,6 +220,7 @@ namespace uCentral::FMSObjects {
field_to_json(Obj, "unknownFirmwares", UnknownFirmwares_);
field_to_json(Obj,"snapshot",snapshot);
field_to_json(Obj,"numberOfDevices",numberOfDevices);
field_to_json(Obj, "totalSecondsOld", totalSecondsOld_);
}
void DeviceReport::reset() {

View File

@@ -122,6 +122,7 @@ namespace uCentral::FMSObjects {
Types::CountedMap EndPoints_;
Types::CountedMap UsingLatest_;
Types::CountedMap UnknownFirmwares_;
Types::CountedMap totalSecondsOld_;
void to_json(Poco::JSON::Object &Obj) const;
void reset();
bool from_json(const Poco::JSON::Object::Ptr &Obj);

View File

@@ -221,7 +221,7 @@ namespace uCentral {
} else if (Age.age == 0) {
Types::UpdateCountedMap(Report.UnknownFirmwares_, Revision);
} else {
Types::UpdateCountedMap(Report.totalSecondsOld_,"total_seconds", Age.age);
}
}
More = RSet.moveNext();

View File

@@ -28,12 +28,12 @@ namespace uCentral::Types {
typedef std::map<std::string, TopicNotifyFunctionList> NotifyTable;
typedef std::map<std::string,uint64_t> CountedMap;
inline void UpdateCountedMap(CountedMap &M, const std::string &S ) {
inline void UpdateCountedMap(CountedMap &M, const std::string &S, uint64_t Increment=1) {
auto it = M.find(S);
if(it==M.end())
M[S]=1;
M[S] = Increment;
else
it->second += 1;
it->second += Increment;
}
};