Skip to content

Commit 62bbe94

Browse files
prakhar10ebyhr
authored andcommitted
Add source filter to History page
1 parent 5eb709a commit 62bbe94

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

gateway-ha/src/main/java/io/trino/gateway/ha/domain/request/QueryHistoryRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public record QueryHistoryRequest(
3131
@JsonProperty("size") Integer size,
3232
@JsonProperty("user") String user,
3333
@JsonProperty("backendUrl") String backendUrl,
34-
@JsonProperty("queryId") String queryId)
34+
@JsonProperty("queryId") String queryId,
35+
@JsonProperty("source") String source)
3536
{
3637
public QueryHistoryRequest
3738
{

gateway-ha/src/main/java/io/trino/gateway/ha/resource/GatewayWebAppResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public Response findQueryHistory(QueryHistoryRequest query, @Context SecurityCon
118118
query.size(),
119119
securityContext.getUserPrincipal().getName(),
120120
query.backendUrl(),
121-
query.queryId()));
121+
query.queryId(),
122+
query.source()));
122123
}
123124
else {
124125
queryHistory = queryHistoryManager.findQueryHistory(query);

gateway-ha/src/main/java/io/trino/gateway/ha/router/HaQueryHistoryManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ public TableData<QueryDetail> findQueryHistory(QueryHistoryRequest query)
110110
if (!Strings.isNullOrEmpty(query.queryId())) {
111111
condition += " and query_id = '" + query.queryId() + "'";
112112
}
113+
if (!Strings.isNullOrEmpty(query.source())) {
114+
condition += " and source = '" + query.source() + "'";
115+
}
113116
List<QueryHistory> histories = dao.pageQueryHistory(condition, query.size(), start);
114117
List<QueryDetail> rows = upcast(histories);
115118
Long total = dao.count(condition);

gateway-ha/src/test/java/io/trino/gateway/ha/TestObjectSerializable.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ void testQueryGlobalPropertyRequest()
122122
void testQueryHistoryRequest()
123123
throws JsonProcessingException
124124
{
125-
assertThat(objectMapper.writeValueAsString(new QueryHistoryRequest(null, null, "user1", "url1", "query_id")))
126-
.contains(ImmutableList.of("\"page\":1", "\"size\":10", "user", "backendUrl", "queryId"));
127-
assertThat(objectMapper.writeValueAsString(new QueryHistoryRequest(5, 6, "user1", "url1", "query_id")))
128-
.contains(ImmutableList.of("\"page\":5", "\"size\":6", "user", "backendUrl", "queryId"));
125+
assertThat(objectMapper.writeValueAsString(new QueryHistoryRequest(null, null, "user1", "url1", "query_id", "source")))
126+
.contains(ImmutableList.of("\"page\":1", "\"size\":10", "user", "backendUrl", "queryId", "source"));
127+
assertThat(objectMapper.writeValueAsString(new QueryHistoryRequest(5, 6, "user1", "url1", "query_id", "source")))
128+
.contains(ImmutableList.of("\"page\":5", "\"size\":6", "user", "backendUrl", "queryId", "source"));
129129
}
130130

131131
@Test

webapp/src/components/history.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export function History() {
9797
</Form.Select>
9898
<Form.Input field='user' label='User' initValue={form.user} disabled={!access.hasRole(Role.ADMIN)} style={{ width: 150 }} showClear />
9999
<Form.Input field='queryId' label='QueryId' style={{ width: 260 }} showClear placeholder={Locale.History.QueryIdTip} />
100+
<Form.Input field='source' label='Source' style={{ width:150 }} showClear />
100101
<Button htmlType='submit' style={{ width: 70 }}>{Locale.UI.Query}</Button>
101102
</>
102103
)}

0 commit comments

Comments
 (0)