Skip to content

Commit

Permalink
Add source filter to History page
Browse files Browse the repository at this point in the history
  • Loading branch information
prakhar10 authored and ebyhr committed Nov 12, 2024
1 parent 5eb709a commit 62bbe94
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public record QueryHistoryRequest(
@JsonProperty("size") Integer size,
@JsonProperty("user") String user,
@JsonProperty("backendUrl") String backendUrl,
@JsonProperty("queryId") String queryId)
@JsonProperty("queryId") String queryId,
@JsonProperty("source") String source)
{
public QueryHistoryRequest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public Response findQueryHistory(QueryHistoryRequest query, @Context SecurityCon
query.size(),
securityContext.getUserPrincipal().getName(),
query.backendUrl(),
query.queryId()));
query.queryId(),
query.source()));
}
else {
queryHistory = queryHistoryManager.findQueryHistory(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public TableData<QueryDetail> findQueryHistory(QueryHistoryRequest query)
if (!Strings.isNullOrEmpty(query.queryId())) {
condition += " and query_id = '" + query.queryId() + "'";
}
if (!Strings.isNullOrEmpty(query.source())) {
condition += " and source = '" + query.source() + "'";
}
List<QueryHistory> histories = dao.pageQueryHistory(condition, query.size(), start);
List<QueryDetail> rows = upcast(histories);
Long total = dao.count(condition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ void testQueryGlobalPropertyRequest()
void testQueryHistoryRequest()
throws JsonProcessingException
{
assertThat(objectMapper.writeValueAsString(new QueryHistoryRequest(null, null, "user1", "url1", "query_id")))
.contains(ImmutableList.of("\"page\":1", "\"size\":10", "user", "backendUrl", "queryId"));
assertThat(objectMapper.writeValueAsString(new QueryHistoryRequest(5, 6, "user1", "url1", "query_id")))
.contains(ImmutableList.of("\"page\":5", "\"size\":6", "user", "backendUrl", "queryId"));
assertThat(objectMapper.writeValueAsString(new QueryHistoryRequest(null, null, "user1", "url1", "query_id", "source")))
.contains(ImmutableList.of("\"page\":1", "\"size\":10", "user", "backendUrl", "queryId", "source"));
assertThat(objectMapper.writeValueAsString(new QueryHistoryRequest(5, 6, "user1", "url1", "query_id", "source")))
.contains(ImmutableList.of("\"page\":5", "\"size\":6", "user", "backendUrl", "queryId", "source"));
}

@Test
Expand Down
1 change: 1 addition & 0 deletions webapp/src/components/history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function History() {
</Form.Select>
<Form.Input field='user' label='User' initValue={form.user} disabled={!access.hasRole(Role.ADMIN)} style={{ width: 150 }} showClear />
<Form.Input field='queryId' label='QueryId' style={{ width: 260 }} showClear placeholder={Locale.History.QueryIdTip} />
<Form.Input field='source' label='Source' style={{ width:150 }} showClear />
<Button htmlType='submit' style={{ width: 70 }}>{Locale.UI.Query}</Button>
</>
)}
Expand Down

0 comments on commit 62bbe94

Please sign in to comment.