@Override public Filters filters(Date from, Date to) { return new Filters(); } }
@Override public Filters filters(Date from, Date to) { try { long start = System.currentTimeMillis(); Timestamp fromTs = new Timestamp(from.getTime()); Timestamp toTs = new Timestamp(to.getTime()); List<String> groups = run.queryExt(20, " SELECT distinct(appGroup) " + " FROM endoscopeGroup " + " WHERE startDate >= ? AND endDate <= ? ", stringHandler, fromTs, toTs); log.debug("Loaded {} groups in {}ms", groups.size(), System.currentTimeMillis() - start); start = System.currentTimeMillis(); List<String> types = run.queryExt(20, " SELECT distinct(appType) " + " FROM endoscopeGroup " + " WHERE startDate >= ? AND endDate <= ? " , stringHandler, fromTs, toTs); log.debug("Loaded {} types in {}ms", types.size(), System.currentTimeMillis() - start); Filters filters = new Filters(groups, types); return filters; } catch (SQLException e) { throw new RuntimeException(e); } }
@Override public Filters findFilters(Date from, Date to, String type){ Set<String> types = new HashSet<>(); Set<String> instances = new HashSet<>(); dir.list((dir, name) -> { GzipFileInfo info = GzipFileInfo.safeParse(name); if( info != null && info.match(from, to, null, type)){ if( info.getInstance() != null ){ instances.add(info.getInstance()); } if( info.getType() != null ){ types.add(info.getType()); } } return false; }); return new Filters(new ArrayList(instances), new ArrayList(types)); }
return new Filters(instances, types, storageInfo(null)); } catch (SQLException e) { throw new RuntimeException(e);
@GET @Path("/data/filters") @Produces("application/json") public Response filters(@QueryParam("from") String from, @QueryParam("to") String to, @QueryParam("past") String past){ TimeRange range = new TimeRange(from, to, past, null, null); Filters filters = null; if( canSearch(range) ){ filters = getStorage().findFilters(range.getFromDate(), range.getToDate(), null); } if( filters == null){ filters = new Filters(null, null); } filters.setInstances(addDefaultAndSort(filters.getInstances(), Properties.getAppInstance())); filters.setTypes( addDefaultAndSort(filters.getTypes(), Properties.getAppType())); return noCacheResponse(jsonUtil.toJson(filters)); }