Search in sources :

Example 1 with GaeLogApi

use of teammates.common.util.GaeLogApi in project teammates by TEAMMATES.

the class AdminEmailLogPageAction method searchEmailLogsWithTimeIncrement.

/**
 * Searches enough email logs within MAX_SEARCH_PERIOD hours.
 */
private void searchEmailLogsWithTimeIncrement(AdminEmailLogPageData data) {
    List<EmailLogEntry> emailLogs = new LinkedList<>();
    List<String> versionToQuery = getVersionsForQuery(data.getVersions());
    AdminLogQuery query = new AdminLogQuery(versionToQuery, null, data.getToDate());
    int totalLogsSearched = 0;
    GaeLogApi logApi = new GaeLogApi();
    long startTime = query.getEndTime() - SEARCH_TIME_INCREMENT;
    query.setTimePeriod(startTime, query.getEndTime());
    for (int i = 0; i < MAX_SEARCH_TIMES; i++) {
        if (emailLogs.size() >= LOGS_PER_PAGE) {
            break;
        }
        List<AppLogLine> searchResult = logApi.fetchLogs(query);
        List<EmailLogEntry> filteredLogs = filterLogsForEmailLogPage(searchResult, data);
        emailLogs.addAll(filteredLogs);
        totalLogsSearched += searchResult.size();
        query.moveTimePeriodBackward(SEARCH_TIME_INCREMENT);
    }
    data.setLogs(emailLogs);
    long nextEndTimeToSearch = query.getEndTime();
    String status = "&nbsp;&nbsp;Total Logs gone through in last search: " + totalLogsSearched + "<br>" + "<button class=\"btn-link\" id=\"button_older\" data-next-end-time-to-search=\"" + nextEndTimeToSearch + "\">Search More</button>";
    data.setStatusForAjax(status);
    statusToUser.add(new StatusMessage(status, StatusMessageColor.INFO));
}
Also used : EmailLogEntry(teammates.common.util.EmailLogEntry) AppLogLine(com.google.appengine.api.log.AppLogLine) LinkedList(java.util.LinkedList) AdminLogQuery(teammates.common.util.AdminLogQuery) GaeLogApi(teammates.common.util.GaeLogApi) StatusMessage(teammates.common.util.StatusMessage)

Example 2 with GaeLogApi

use of teammates.common.util.GaeLogApi in project teammates by TEAMMATES.

the class AdminActivityLogPageAction method searchLogsWithExactTimePeriod.

/**
 * Retrieves all logs in the time period specified in the query.
 */
private List<ActivityLogEntry> searchLogsWithExactTimePeriod(AdminLogQuery query, AdminActivityLogPageData data) {
    GaeLogApi logApi = new GaeLogApi();
    List<AppLogLine> searchResult = logApi.fetchLogs(query);
    nextEndTimeToSearch = data.getFromDate() - 1;
    totalLogsSearched = searchResult.size();
    return filterLogsForActivityLogPage(searchResult, data);
}
Also used : AppLogLine(com.google.appengine.api.log.AppLogLine) GaeLogApi(teammates.common.util.GaeLogApi)

Example 3 with GaeLogApi

use of teammates.common.util.GaeLogApi in project teammates by TEAMMATES.

the class AdminActivityLogPageAction method searchLogsWithTimeIncrement.

/**
 * Retrieves enough logs within MAX_SEARCH_PERIOD hours.
 */
private List<ActivityLogEntry> searchLogsWithTimeIncrement(AdminLogQuery query, AdminActivityLogPageData data) {
    List<ActivityLogEntry> appLogs = new LinkedList<>();
    totalLogsSearched = 0;
    GaeLogApi logApi = new GaeLogApi();
    long startTime = query.getEndTime() - SEARCH_TIME_INCREMENT;
    query.setTimePeriod(startTime, query.getEndTime());
    for (int i = 0; i < MAX_SEARCH_TIMES; i++) {
        if (appLogs.size() >= RELEVANT_LOGS_PER_PAGE) {
            break;
        }
        List<AppLogLine> searchResult = logApi.fetchLogs(query);
        List<ActivityLogEntry> filteredLogs = filterLogsForActivityLogPage(searchResult, data);
        appLogs.addAll(filteredLogs);
        totalLogsSearched += searchResult.size();
        query.moveTimePeriodBackward(SEARCH_TIME_INCREMENT);
    }
    data.setFromDate(query.getStartTime() + SEARCH_TIME_INCREMENT);
    nextEndTimeToSearch = query.getEndTime();
    return appLogs;
}
Also used : ActivityLogEntry(teammates.common.util.ActivityLogEntry) AppLogLine(com.google.appengine.api.log.AppLogLine) LinkedList(java.util.LinkedList) GaeLogApi(teammates.common.util.GaeLogApi)

Example 4 with GaeLogApi

use of teammates.common.util.GaeLogApi in project teammates by TEAMMATES.

the class AdminEmailLogPageAction method searchEmailLogsWithExactTimePeriod.

/**
 * Searches all logs in the time period specified in the query.
 */
private void searchEmailLogsWithExactTimePeriod(AdminEmailLogPageData data) {
    List<String> versionToQuery = getVersionsForQuery(data.getVersions());
    AdminLogQuery query = new AdminLogQuery(versionToQuery, data.getFromDate(), data.getToDate());
    List<AppLogLine> searchResult = new GaeLogApi().fetchLogs(query);
    data.setLogs(filterLogsForEmailLogPage(searchResult, data));
    long nextEndTimeToSearch = data.getFromDate() - 1;
    int totalLogsSearched = searchResult.size();
    String status = "&nbsp;&nbsp;Total Logs gone through in last search: " + totalLogsSearched + "<br>" + "<button class=\"btn-link\" id=\"button_older\" data-next-end-time-to-search=\"" + nextEndTimeToSearch + "\">Search More</button>";
    data.setStatusForAjax(status);
    statusToUser.add(new StatusMessage(status, StatusMessageColor.INFO));
}
Also used : AppLogLine(com.google.appengine.api.log.AppLogLine) AdminLogQuery(teammates.common.util.AdminLogQuery) GaeLogApi(teammates.common.util.GaeLogApi) StatusMessage(teammates.common.util.StatusMessage)

Aggregations

AppLogLine (com.google.appengine.api.log.AppLogLine)4 GaeLogApi (teammates.common.util.GaeLogApi)4 LinkedList (java.util.LinkedList)2 AdminLogQuery (teammates.common.util.AdminLogQuery)2 StatusMessage (teammates.common.util.StatusMessage)2 ActivityLogEntry (teammates.common.util.ActivityLogEntry)1 EmailLogEntry (teammates.common.util.EmailLogEntry)1