Skip to content

Commit

Permalink
Implemented 'options=count'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Zangelin committed Aug 13, 2015
1 parent a8bb8db commit a3fa6aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/lib/serviceRoutinesV2/getEntityAllTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,22 @@ std::string getEntityAllTypes

mongoEntityTypes(&response, ciP->tenant, ciP->servicePathV, ciP->uriParam);
answer = response.toJson(ciP);
response.release();

if (ciP->uriParam["options"] == "count")
{
long long acc = 0;
char cVec[64];

for (unsigned int ix = 0; ix < response.typeEntityVector.size(); ++ix)
{
acc += response.typeEntityVector[ix]->count;
}

snprintf(cVec, sizeof(cVec), "%lld", acc);
ciP->httpHeader.push_back("X-Total-Count");
ciP->httpHeaderValue.push_back(cVec);
}

response.release();
return answer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ echo

echo "08. GET /v2/type and get a list of three types, T3 now has three attributes and two entities"
echo "============================================================================================"
orionCurl --url /v2/type --json
orionCurl --url /v2/type?options=count --json
echo
echo

Expand Down Expand Up @@ -239,6 +239,7 @@ Date: REGEX(.*)
HTTP/1.1 200 OK
Content-Length: 233
Content-Type: application/json
X-Total-Count: 4
Date: REGEX(.*)

{
Expand Down

0 comments on commit a3fa6aa

Please sign in to comment.