mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-17 20:50:44 +00:00
Add count distinct option to count action
This commit is contained in:
@ -788,6 +788,7 @@ public class QJavalinImplementation
|
||||
}
|
||||
|
||||
countInput.setQueryJoins(processQueryJoinsParam(context));
|
||||
countInput.setIncludeDistinctCount(QJavalinUtils.queryParamIsTrue(context, "includeDistinct"));
|
||||
|
||||
CountAction countAction = new CountAction();
|
||||
CountOutput countOutput = countAction.execute(countInput);
|
||||
@ -861,6 +862,11 @@ public class QJavalinImplementation
|
||||
|
||||
QueryAction queryAction = new QueryAction();
|
||||
QueryOutput queryOutput = queryAction.execute(queryInput);
|
||||
int rowIndex = 0;
|
||||
for(QRecord record : queryOutput.getRecords())
|
||||
{
|
||||
record.setValue("__qRowIndex", rowIndex++);
|
||||
}
|
||||
|
||||
QJavalinAccessLogger.logEndSuccess(logPair("recordCount", queryOutput.getRecords().size()), logPairIfSlow("filter", filter, SLOW_LOG_THRESHOLD_MS));
|
||||
context.result(JsonUtils.toJson(queryOutput));
|
||||
|
@ -22,6 +22,7 @@
|
||||
package com.kingsrook.qqq.backend.javalin;
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QValueException;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
||||
@ -52,6 +53,23 @@ public class QJavalinUtils
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Returns true iff context has a valid query parameter by the given name, with
|
||||
** a value of "true".
|
||||
*******************************************************************************/
|
||||
public static boolean queryParamIsTrue(Context context, String name) throws QValueException
|
||||
{
|
||||
String value = context.queryParam(name);
|
||||
if(Objects.equals(value, "true"))
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Returns Integer if context has a valid int form parameter by the given name,
|
||||
** Returns null if no param (or empty value).
|
||||
|
Reference in New Issue
Block a user