@RequestMapping(value = "/activities", method = RequestMethod.GET)
  @Interceptors({CompanyMemberRequired.class})
  @ResponseBody
  public CompanyActivities showActivities(
      @PathVariable int companyId,
      @RequestParam(value = "until", required = false) @DateTimeFormat(iso = ISO.DATE) Date until,
      @RequestParam(required = false) Integer userId,
      @RequestParam(required = false) Integer projectId,
      @RequestParam(required = false) String type) {
    DateTime dt = until == null ? new DateTime() : new DateTime(until);
    until = dt.withTime(0, 0, 0, 0).plusDays(1).plusMillis(-1).toDate();
    boolean hasNext = false;
    Date nextDay = null;

    List<Activity> activities =
        activityService.getUserVisibleTillDay(companyId, userId, projectId, until, type, LIMIT);

    if (activities.size() > 0) {

      Activity activity = activities.get(activities.size() - 1);
      nextDay = new DateTime(activity.getCreated()).withTime(0, 0, 0, 0).plusMillis(-1).toDate();

      // 如果取到nextDay仍然有数据,则hasNext为true
      List<Activity> nextActivities =
          activityService.getUserVisibleTillDay(companyId, userId, projectId, nextDay, type, LIMIT);

      if (nextActivities.size() > 0) {
        hasNext = true;
      }
    }
    return new CompanyActivities(activities, hasNext, nextDay);
  }
Beispiel #2
0
  @Override
  public ConnectorSplitSource getSplits(
      ConnectorTransactionHandle transactionHandle,
      ConnectorSession session,
      ConnectorTableLayoutHandle layoutHandle) {
    AtopTableLayoutHandle handle =
        checkType(layoutHandle, AtopTableLayoutHandle.class, "layoutHandle");

    AtopTableHandle table = handle.getTableHandle();

    List<ConnectorSplit> splits = new ArrayList<>();
    DateTime end = DateTime.now().withZone(timeZone);
    for (Node node : nodeManager.getActiveDatasourceNodes(connectorId.getId())) {
      DateTime start = end.minusDays(maxHistoryDays - 1).withTimeAtStartOfDay();
      while (start.isBefore(end)) {
        DateTime splitEnd = start.withTime(23, 59, 59, 999);
        Domain splitDomain =
            Domain.create(
                ValueSet.ofRanges(
                    Range.range(TIMESTAMP, start.getMillis(), true, splitEnd.getMillis(), true)),
                false);
        if (handle.getStartTimeConstraint().overlaps(splitDomain)
            && handle.getEndTimeConstraint().overlaps(splitDomain)) {
          splits.add(new AtopSplit(table.getTable(), node.getHostAndPort(), start));
        }
        start = start.plusDays(1).withTimeAtStartOfDay();
      }
    }

    return new FixedSplitSource(connectorId.getId(), splits);
  }
Beispiel #3
0
 /** Resets time of provided dateTime to (D+1)midnight-1ms */
 public static DateTime toStartHour(DateTime dateTime) {
   return dateTime.withTime(dateTime.getHourOfDay(), 0, 0, 0);
 }
Beispiel #4
0
 /** Resets time of provided dateTime to (D+1)midnight-1ms */
 public static DateTime toEndDay(DateTime dateTime) {
   return dateTime.withTime(23, 59, 59, 999);
 }