public static Query<AppResult> generateUserApplicationSummaryQuery(List<String> usernames,
      Map<String, String> searchParams, String sortKey, boolean increasing) {
    ExpressionList<AppResult> query = AppResult.find.select(AppResult.getSearchFields()).where();
    Junction<AppResult> junction = query.disjunction();
    for (String username : usernames) {
      junction.eq(AppResult.TABLE.USERNAME, username);
    }
    query.endJunction();

    String finishedTimeBegin = searchParams.get(Application.FINISHED_TIME_BEGIN);
    if (!Utils.isSet(finishedTimeBegin)) {
      finishedTimeBegin = String.valueOf(System.currentTimeMillis() - 7 * DAY); // week of data if not specified
    }

    long time = parseTime(finishedTimeBegin);
    if (time > 0) {
      query.ge(AppResult.TABLE.FINISH_TIME, time);
    }

    String finishedTimeEnd = searchParams.get(Application.FINISHED_TIME_END);
    if (!Utils.isSet(finishedTimeEnd)) {
      finishedTimeEnd = String.valueOf(System.currentTimeMillis());
    }

    time = parseTime(finishedTimeEnd);
    if (time > 0) {
      query.le(AppResult.TABLE.FINISH_TIME, time);
    }

    if (increasing) {
      return query.order(getSortKey(sortKey));
    } else {
      return query.order().desc(getSortKey(sortKey));
    }
  }
Generates the query for returning the application summaries
@param usernames The list of usernames
@param searchParams Any additional parameters
@param sortKey The key on which the applications should be sorted
@param increasing The boolean value to sort the output based on the key desc or increasing
@return The Query object based on the given above parameters
app/controllers/api/v1/Web.java