Skip to content

Commit

Permalink
shortening of processing of empty result set
Browse files Browse the repository at this point in the history
for csv output in /groupBy/tag requests
  • Loading branch information
FabiKo117 committed Aug 24, 2020
1 parent dbf44a1 commit 90c0fbb
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ public void writeCsvResponse(GroupByObject[] resultSet, HttpServletResponse serv
Pair<List<String>, List<String[]>> rows;
if (resultSet instanceof GroupByResult[]) {
if (resultSet.length == 0) {
List<String> column = new ArrayList<>();
column.add("timestamp");
rows = new ImmutablePair<>(column, null);
writer.writeNext(new String[] {"timestamp"}, false);
writer.close();
return;
} else {
GroupByResult result = (GroupByResult) resultSet[0];
if (result.getResult() instanceof UsersResult[]) {
Expand All @@ -307,12 +307,8 @@ public void writeCsvResponse(GroupByObject[] resultSet, HttpServletResponse serv
rows = createCsvResponseForElementsRatioGroupBy(resultSet);
}
writer.writeNext(rows.getLeft().toArray(new String[rows.getLeft().size()]), false);
if (rows.getRight() != null) {
writer.writeAll(rows.getRight(), false);
writer.close();
} else {
writer.close();
}
writer.writeAll(rows.getRight(), false);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 90c0fbb

Please sign in to comment.