summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiaqing Zhao <jiaqing.zhao@intel.com>2022-07-22 04:33:33 +0300
committerJiaqing Zhao <jiaqing.zhao@intel.com>2022-08-19 11:31:56 +0300
commit5143f7a5417524c23a41c486dba1baa48767dc3c (patch)
tree789168710dd0a64fb132ab284a047fe46792fce9
parent60a86d6c3d0d7afce431e7ae6b1299e7ea7cbb8c (diff)
downloadbmcweb-5143f7a5417524c23a41c486dba1baa48767dc3c.tar.xz
query_param: Move maxEntriesPerPage to Query struct
Putting the maxEntriesPerPage next to the top parameter makes it more clear about its intention as Ed suggested. Here it is also renamed to maxTop to illustrate its relationship with top. Tested: Build, unit test and Redfish Service Validator passed. Change-Id: I035eea7e33d78439685a81092a4dd9332cfc501a Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
-rw-r--r--redfish-core/include/utils/query_param.hpp7
-rw-r--r--redfish-core/lib/log_services.hpp12
2 files changed, 7 insertions, 12 deletions
diff --git a/redfish-core/include/utils/query_param.hpp b/redfish-core/include/utils/query_param.hpp
index 5e9ef13e4e..f51993ea90 100644
--- a/redfish-core/include/utils/query_param.hpp
+++ b/redfish-core/include/utils/query_param.hpp
@@ -49,7 +49,6 @@ namespace redfish
{
namespace query_param
{
-inline constexpr size_t maxEntriesPerPage = 1000;
enum class ExpandType : uint8_t
{
@@ -178,6 +177,7 @@ struct Query
std::optional<size_t> skip = std::nullopt;
// Top
+ static constexpr size_t maxTop = 1000; // Max entries a response contain
std::optional<size_t> top = std::nullopt;
// Select
@@ -334,7 +334,7 @@ inline QueryError getTopParam(std::string_view value, Query& query)
}
// Range check for sanity.
- if (query.top > maxEntriesPerPage)
+ if (query.top > Query::maxTop)
{
return QueryError::OutOfRange;
}
@@ -411,8 +411,7 @@ inline std::optional<Query>
if (topRet == QueryError::OutOfRange)
{
messages::queryParameterOutOfRange(
- res, value, "$top",
- "0-" + std::to_string(maxEntriesPerPage));
+ res, value, "$top", "0-" + std::to_string(Query::maxTop));
return std::nullopt;
}
}
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 8c062aaaeb..ee3ccfc6c4 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1170,8 +1170,7 @@ inline void requestRoutesJournalEventLogEntryCollection(App& app)
{
return;
}
- size_t top =
- delegatedQuery.top.value_or(query_param::maxEntriesPerPage);
+ size_t top = delegatedQuery.top.value_or(query_param::Query::maxTop);
size_t skip = delegatedQuery.skip.value_or(0);
// Collections don't include the static data added by SubRoute
@@ -1899,8 +1898,7 @@ inline void requestRoutesSystemHostLoggerCollection(App& app)
}
// If we weren't provided top and skip limits, use the defaults.
size_t skip = delegatedQuery.skip.value_or(0);
- size_t top =
- delegatedQuery.top.value_or(query_param::maxEntriesPerPage);
+ size_t top = delegatedQuery.top.value_or(query_param::Query::maxTop);
size_t logCount = 0;
// This vector only store the entries we want to expose that
// control by skip and top.
@@ -2200,8 +2198,7 @@ inline void requestRoutesBMCJournalLogEntryCollection(App& app)
}
size_t skip = delegatedQuery.skip.value_or(0);
- size_t top =
- delegatedQuery.top.value_or(query_param::maxEntriesPerPage);
+ size_t top = delegatedQuery.top.value_or(query_param::Query::maxTop);
// Collections don't include the static data added by SubRoute
// because it has a duplicate entry for members
@@ -3512,8 +3509,7 @@ inline void requestRoutesPostCodesEntryCollection(App& app)
asyncResp->res.jsonValue["Members"] = nlohmann::json::array();
asyncResp->res.jsonValue["Members@odata.count"] = 0;
size_t skip = delegatedQuery.skip.value_or(0);
- size_t top =
- delegatedQuery.top.value_or(query_param::maxEntriesPerPage);
+ size_t top = delegatedQuery.top.value_or(query_param::Query::maxTop);
getCurrentBootNumber(asyncResp, skip, top);
});
}