Skip to content

Commit

Permalink
Move getStart to HaQueryHistoryManager
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr authored and oneonestar committed Oct 3, 2024
1 parent 82498c1 commit cb5869f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.trino.gateway.ha.domain.response.DistributionResponse;
import io.trino.gateway.ha.persistence.dao.QueryHistory;
import io.trino.gateway.ha.persistence.dao.QueryHistoryDao;
import io.trino.gateway.ha.util.PageUtil;
import org.jdbi.v3.core.Jdbi;

import java.time.Instant;
Expand All @@ -36,6 +35,8 @@
public class HaQueryHistoryManager
implements QueryHistoryManager
{
private static final int FIRST_PAGE_NO = 1;

private final QueryHistoryDao dao;

public HaQueryHistoryManager(Jdbi jdbi)
Expand Down Expand Up @@ -98,7 +99,7 @@ public String getBackendForQueryId(String queryId)
@Override
public TableData<QueryDetail> findQueryHistory(QueryHistoryRequest query)
{
int start = PageUtil.getStart(query.page(), query.size());
int start = getStart(query.page(), query.size());
String condition = "";
if (!Strings.isNullOrEmpty(query.user())) {
condition += " and user_name = '" + query.user() + "'";
Expand Down Expand Up @@ -133,4 +134,15 @@ public List<DistributionResponse.LineChart> findDistribution(Long ts)
}
return resList;
}

private static int getStart(int pageNo, int pageSize)
{
if (pageNo < FIRST_PAGE_NO) {
pageNo = FIRST_PAGE_NO;
}
if (pageSize < 1) {
pageSize = 0;
}
return (pageNo - FIRST_PAGE_NO) * pageSize;
}
}
32 changes: 0 additions & 32 deletions gateway-ha/src/main/java/io/trino/gateway/ha/util/PageUtil.java

This file was deleted.

0 comments on commit cb5869f

Please sign in to comment.