<commit_before>package de.iteratec.osm.result

import de.iteratec.osm.api.MicroServiceApiKey
import de.iteratec.osm.measurement.schedule.dao.JobGroupDaoService
import grails.web.mapping.LinkGenerator
import groovyx.net.http.RESTClient

import java.lang.reflect.InvocationTargetException

class DetailAnalysisController {
    JobGroupDaoService jobGroupDaoService
    LinkGenerator grailsLinkGenerator

    public final static String DATE_FORMAT_STRING = 'dd.mm.yyyy';

    def show() {
        Map modelToRender = [:]

        String osmUrl = grailsLinkGenerator.getServerBaseURL()
        def errorList = []

        if (!osmUrl) {
            errorList << message(code: 'default.serverUrl.undefined', args: [message(code: 'default.serverUrl.undefined', default: 'The server url is undefined. You can set it in the custom osm-properties.\n')])
        }
        String microServiceUrl = grailsApplication.config.getProperty('grails.de.iteratec.osm.assetRequests.microserviceUrl')
        microServiceUrl = microServiceUrl.endsWith("/")?microServiceUrl: microServiceUrl + "/"
        if (!microServiceUrl) {
            errorList << message(code: 'default.microService.osmDetailAnalysis.url.undefined', args: [message(code: 'default.microService.osmDetailAnalysis.url.undefined', default: 'The url for the OsmDetailAnalysis micro service is undefined. You can set it in the custom osm-properties.\n')])
        } else {
            microServiceUrl = microServiceUrl.endsWith("/") ? microServiceUrl : "${microServiceUrl}/"
        }

        String apiKey = MicroServiceApiKey.findByMicroService("OsmDetailAnalysis").secretKey
        if (!apiKey) {
            errorList << message(code: 'default.microService.osmDetailAnalysis.apiKey.undefined', args: [message(code: 'default.microService.osmDetailAnalysis.apiKey.undefined', default: 'The api key for the OsmDetailAnalysis micro service is undefined. You can set it in the custom osm-properties.\n')])
        }
        if (osmUrl && microServiceUrl && apiKey) {
            try {

                if (osmUrl.endsWith("/")) osmUrl = osmUrl.substring(0, osmUrl.length() - 1)
                String detailDataWebPageAsString = new URL(microServiceUrl + "detailAnalysisDashboard/show" + "?apiKey=" + apiKey + "&osmUrl=" + osmUrl + "&" + request.queryString).getText()
                modelToRender.put("osmDetailAnalysisRequest", detailDataWebPageAsString)
            } catch (InvocationTargetException ex) {<commit_msg>added support for relative time frames in the detailAnalysisDashboard<commit_after>package de.iteratec.osm.result

import de.iteratec.osm.api.MicroServiceApiKey
import de.iteratec.osm.measurement.schedule.dao.JobGroupDaoService
import grails.web.mapping.LinkGenerator
import groovyx.net.http.RESTClient

import java.lang.reflect.InvocationTargetException

class DetailAnalysisController {
    JobGroupDaoService jobGroupDaoService
    LinkGenerator grailsLinkGenerator

    public final static String DATE_FORMAT_STRING = 'dd.mm.yyyy';

    def show(EventResultDashboardShowAllCommand cmd) {
        Map modelToRender = [:]

        String osmUrl = grailsLinkGenerator.getServerBaseURL()
        def errorList = []

        if (!osmUrl) {
            errorList << message(code: 'default.serverUrl.undefined', args: [message(code: 'default.serverUrl.undefined', default: 'The server url is undefined. You can set it in the custom osm-properties.\n')])
        }
        String microServiceUrl = grailsApplication.config.getProperty('grails.de.iteratec.osm.assetRequests.microserviceUrl')
        microServiceUrl = microServiceUrl.endsWith("/")?microServiceUrl: microServiceUrl + "/"
        if (!microServiceUrl) {
            errorList << message(code: 'default.microService.osmDetailAnalysis.url.undefined', args: [message(code: 'default.microService.osmDetailAnalysis.url.undefined', default: 'The url for the OsmDetailAnalysis micro service is undefined. You can set it in the custom osm-properties.\n')])
        } else {
            microServiceUrl = microServiceUrl.endsWith("/") ? microServiceUrl : "${microServiceUrl}/"
        }

        String apiKey = MicroServiceApiKey.findByMicroService("OsmDetailAnalysis").secretKey
        if (!apiKey) {
            errorList << message(code: 'default.microService.osmDetailAnalysis.apiKey.undefined', args: [message(code: 'default.microService.osmDetailAnalysis.apiKey.undefined', default: 'The api key for the OsmDetailAnalysis micro service is undefined. You can set it in the custom osm-properties.\n')])
        }
        if (osmUrl && microServiceUrl && apiKey) {
            try {
                if (osmUrl.endsWith("/")) osmUrl = osmUrl.substring(0, osmUrl.length() - 1)
                def timeFrame = cmd.getSelectedTimeFrame()
                String queryString = "?apiKey=${apiKey}&osmUrl=${osmUrl}&toDate=${timeFrame.endMillis}&fromDate=${timeFrame.startMillis}&" + request.queryString
                String detailDataWebPageAsString = new URL(microServiceUrl + "detailAnalysisDashboard/show" + queryString).getText()
                modelToRender.put("osmDetailAnalysisRequest", detailDataWebPageAsString)
            } catch (InvocationTargetException ex) {
{'fraction_non_alphanumeric': 0.10490856592877768, 'fraction_numerical': 0.0007699711260827719, 'mean_word_length': 3.7150635208711433, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '421537', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1412, 'n_words': 308}