mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-06 00:09:22 +00:00
fix: pagination and show message for aggregation query (#3628)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new tracking mechanism for total counts and aggregation status in logs. - Enhanced pagination logic to account for aggregation presence. - **Improvements** - Refined the handling of start and end times in logs. - Improved the logic for displaying histograms and aggregations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -212,6 +212,11 @@ const searchObjDebug = reactive({
|
||||
extractFieldsWithAPI: "",
|
||||
});
|
||||
|
||||
const searchAggData = reactive({
|
||||
total: 0,
|
||||
hasAggregation: false,
|
||||
});
|
||||
|
||||
const useLogs = () => {
|
||||
const store = useStore();
|
||||
const { t } = useI18n();
|
||||
@@ -638,11 +643,13 @@ const useLogs = () => {
|
||||
|
||||
searchObj.data.query = query;
|
||||
const parsedSQL: any = fnParsedSQL();
|
||||
const histogramParsedSQL: any = fnHistogramParsedSQL(req.aggs.histogram);
|
||||
const histogramParsedSQL: any = fnHistogramParsedSQL(
|
||||
req.aggs.histogram
|
||||
);
|
||||
|
||||
histogramParsedSQL.where = parsedSQL.where;
|
||||
|
||||
let histogramQuery = parser.sqlify(histogramParsedSQL)
|
||||
let histogramQuery = parser.sqlify(histogramParsedSQL);
|
||||
histogramQuery = histogramQuery.replace(/`/g, '"');
|
||||
req.aggs.histogram = histogramQuery;
|
||||
|
||||
@@ -823,7 +830,7 @@ const useLogs = () => {
|
||||
}
|
||||
|
||||
const isNonAggregatedQuery = (parsedSQL: any = null) => {
|
||||
return !(parsedSQL?.limit);
|
||||
return !parsedSQL?.limit;
|
||||
};
|
||||
|
||||
const getQueryPartitions = async (queryReq: any) => {
|
||||
@@ -1208,8 +1215,10 @@ const useLogs = () => {
|
||||
router.currentRoute.value.name == "logs" &&
|
||||
searchObj.data.queryResults.hasOwnProperty("hits")
|
||||
) {
|
||||
const start_time: number = initialQueryPayload.value?.query?.start_time || 0;
|
||||
const end_time: number = initialQueryPayload.value?.query?.end_time || 0;
|
||||
const start_time: number =
|
||||
initialQueryPayload.value?.query?.start_time || 0;
|
||||
const end_time: number =
|
||||
initialQueryPayload.value?.query?.end_time || 0;
|
||||
queryReq.query.start_time = start_time;
|
||||
queryReq.query.end_time = end_time;
|
||||
}
|
||||
@@ -1511,9 +1520,9 @@ const useLogs = () => {
|
||||
// ) {
|
||||
// delete queryReq.query.track_total_hits;
|
||||
// }
|
||||
const parsedSQL: any = fnParsedSQL();
|
||||
searchObj.meta.resultGrid.showPagination = true;
|
||||
if (searchObj.meta.sqlMode == true) {
|
||||
const parsedSQL: any = fnParsedSQL();
|
||||
if (parsedSQL.limit != null) {
|
||||
queryReq.query.size = parsedSQL.limit.value[0].value;
|
||||
searchObj.meta.resultGrid.showPagination = false;
|
||||
@@ -1559,6 +1568,17 @@ const useLogs = () => {
|
||||
}
|
||||
}
|
||||
|
||||
searchAggData.total = 0;
|
||||
searchAggData.hasAggregation = false;
|
||||
if (searchObj.meta.sqlMode == true) {
|
||||
if (hasAggregation(parsedSQL?.columns) || parsedSQL.groupby != null) {
|
||||
const parsedSQL: any = fnParsedSQL();
|
||||
searchAggData.total = res.data.total;
|
||||
searchAggData.hasAggregation = true;
|
||||
searchObj.meta.resultGrid.showPagination = false;
|
||||
}
|
||||
}
|
||||
|
||||
let regeratePaginationFlag = false;
|
||||
if (res.data.hits.length != searchObj.meta.resultGrid.rowsPerPage) {
|
||||
regeratePaginationFlag = true;
|
||||
@@ -2178,6 +2198,10 @@ const useLogs = () => {
|
||||
endCount = searchObj.meta.resultGrid.rowsPerPage * (currentPage + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (searchObj.meta.sqlMode && searchAggData.hasAggregation) {
|
||||
totalCount = searchAggData.total;
|
||||
}
|
||||
const title =
|
||||
"Showing " +
|
||||
startCount +
|
||||
@@ -2848,6 +2872,7 @@ const useLogs = () => {
|
||||
|
||||
return {
|
||||
searchObj,
|
||||
searchAggData,
|
||||
getStreams,
|
||||
resetSearchObj,
|
||||
resetStreamData,
|
||||
|
||||
Reference in New Issue
Block a user