All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.rbmhtechnology.vind.monitoring.analysis.BasicReportAnalyzer Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version

package com.rbmhtechnology.vind.monitoring.analysis;

import com.rbmhtechnology.vind.monitoring.logger.entry.FullTextEntry;
import com.rbmhtechnology.vind.monitoring.logger.entry.MonitoringEntry;
import com.rbmhtechnology.vind.monitoring.logger.entry.SuggestionEntry;
import com.rbmhtechnology.vind.monitoring.model.request.SuggestionRequest;

import java.util.Collection;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Created on 08.01.18.
 */
public class BasicReportAnalyzer extends LogAnalyzer{


    @Override
    public String analyze(MonitoringEntry log) {
        return null;
    }

    @Override
    public String analyze(Collection  log) {

        //General Info
        ///Name
        ///App
        ///Workspace
        ///Module
        ///from Date
        ///to Date

        //Total number of requests
        final long requests = log.size();

        //Top Day
        final Map topDays = log.stream().map(logEntry -> logEntry.getTimeStamp().getDayOfYear())
                .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
        //Top users
        final Map topSessions = log.stream().map(logEntry -> logEntry.getSession().getSessionId())
                .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));

        //Facets
        ///Facet Fields

        ///Facet Values per field?

        //Suggestions
        ///Suggestion fields
        final Map suggestionFields = log.stream()
                .filter(logEntry -> logEntry.getType().name().equals(MonitoringEntry.EntryType.suggestion))
                .map(logEntry -> ((SuggestionRequest) ((SuggestionEntry)logEntry).getRequest()).getSuggestionFields())
                .flatMap(fields -> fields.stream())
                .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
        ///Suggestion values per field

        //Advanced search?
        ///Advanced search fields
        ///Advanced search values per field

        //Full Text
        ///Fulltext top queries
        final Map fulltextQueries = log.stream()
                .filter(logEntry -> logEntry.getType().name().equals(MonitoringEntry.EntryType.fulltext))
                .map(logEntry -> ((FullTextEntry)logEntry).getRequest().getQuery())
                .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
        //Filtered fulltext top queries?

        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy