mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Add dedicated method for api count in baseApiActionUtil; improve null handling in json to record
This commit is contained in:
@ -266,6 +266,12 @@ public class JsonUtils
|
||||
}
|
||||
}
|
||||
|
||||
if(jsonObjectToUse.isNull(backendName))
|
||||
{
|
||||
record.setValue(fieldName, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(metaData.getType())
|
||||
{
|
||||
case INTEGER -> record.setValue(fieldName, jsonObjectToUse.optInt(backendName));
|
||||
|
@ -22,13 +22,11 @@
|
||||
package com.kingsrook.qqq.backend.module.api.actions;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import com.kingsrook.qqq.backend.core.actions.interfaces.CountInterface;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
@ -71,10 +69,10 @@ public class APICountAction extends AbstractAPIAction implements CountInterface
|
||||
apiActionUtil.setupAdditionalHeaders(request);
|
||||
|
||||
HttpResponse response = client.execute(request);
|
||||
List<QRecord> queryResults = apiActionUtil.processGetResponse(table, response);
|
||||
Integer count = apiActionUtil.processGetResponseForCount(table, response);
|
||||
|
||||
CountOutput rs = new CountOutput();
|
||||
rs.setCount(queryResults.size());
|
||||
rs.setCount(count);
|
||||
return rs;
|
||||
}
|
||||
catch(Exception e)
|
||||
|
@ -458,4 +458,16 @@ public class BaseAPIActionUtil
|
||||
{
|
||||
return (jsonObjectToRecord(getJsonObject(response), table.getFields()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public Integer processGetResponseForCount(QTableMetaData table, HttpResponse response) throws IOException
|
||||
{
|
||||
List<QRecord> queryResults = processGetResponse(table, response);
|
||||
return (queryResults.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ checkBuild()
|
||||
color="gray"
|
||||
fi
|
||||
|
||||
if [ $index -lt 1 -o $seconds -lt 300 ]; then
|
||||
if [ $index -lt 1 -o $seconds -lt 600 ]; then
|
||||
echo -n "${shortRepo}(${shortAge})${icon} "
|
||||
fi
|
||||
details="$details\n$repo: $jobName: $buildStatus @ $age ago | color=$color | href=$url | image=$avatarB64"
|
||||
|
Reference in New Issue
Block a user