<commit_before>package org.onedatashare.server.service;

import com.sun.research.ws.wadl.Param;
import lombok.SneakyThrows;
import org.onedatashare.server.model.requestdata.BatchJobData;
import org.onedatashare.server.model.requestdata.InfluxData;
import org.onedatashare.server.model.requestdata.MonitorData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.util.UriComponentsBuilder;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.net.URI;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class MetaDataService {

    @Value("${meta.service.uri}")
    private String metaHostName;

    private Logger logger = LoggerFactory.getLogger(MetaDataService.class);
    private String MONITOR = "/monitor";
    private String USER_EMAIL = "userEmail";
    private String BASE_PATH = "/api/v1/meta";
    private String USER_JOBS = "/user_jobs";
    private String STAT = "/stat";
    private String JOB_ID_QUERY = "jobId";
    private String ALL_STATS = "/all_stats";
    private String INFLUX_RANGE_MEASUREMENTS = "/stats/influx/job/range";
    private String INFLUX_JOB_MEASUREMENTS = "/stats/influx/job";
    private String INFLUX_USER_MEASUREMENTS = "/stats/influx/user";
    private String DATE = "/date";

    @Autowired
    private WebClient.Builder webClientBuilder;

    //CockroachDB data calls below

    @SneakyThrows
    public Mono<List<Long>> getAllJobIds(String userId) {
        logger.info("Querying all user jobs {}", userId);
        URI uri = UriComponentsBuilder.fromUriString(this.metaHostName)
                .path(BASE_PATH + USER_JOBS)
                .queryParam(USER_EMAIL, userId)
                .build().toUri();
        logger.info(uri.toString());
        return this.webClientBuilder.build()
                .get()
                .uri(uri)
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<List<Long>>() {
                });
    }

    @SneakyThrows
    public Mono<List<BatchJobData>> getAllStats(String userId) {
        logger.info("the userId we are querying for is {}", userId);
        URI uri = UriComponentsBuilder.fromUriString(this.metaHostName)
                .path(BASE_PATH + ALL_STATS)
                .queryParam(USER_EMAIL, userId)
                .build().toUri();
        logger.info(uri.toString());
        return this.webClientBuilder.build()
                .get()
                .uri(uri)
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<List<BatchJobData>>() {
                });
    }

    public Mono<Page<BatchJobData>> getAllStats(String userId, Integer page, Integer size, String sort, String direction) {
        URI uri = UriComponentsBuilder.fromUriString("http://localhost:8084")
                .path(BASE_PATH + "/stat/page")
                .queryParam(USER_EMAIL, userId)
                .queryParam("page", page)
                .queryParam("size", size)
                .queryParam("direction", direction)
                .queryParam("sort", sort)
                .build().toUri();
        logger.info(uri.toString());
        return WebClient.builder().build()
                .get()
                .uri(uri)
                .retrieve()<commit_msg>forgot to remove this<commit_after>package org.onedatashare.server.service;

import com.sun.research.ws.wadl.Param;
import lombok.SneakyThrows;
import org.onedatashare.server.model.requestdata.BatchJobData;
import org.onedatashare.server.model.requestdata.InfluxData;
import org.onedatashare.server.model.requestdata.MonitorData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.util.UriComponentsBuilder;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.net.URI;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class MetaDataService {

    @Value("${meta.service.uri}")
    private String metaHostName;

    private Logger logger = LoggerFactory.getLogger(MetaDataService.class);
    private String MONITOR = "/monitor";
    private String USER_EMAIL = "userEmail";
    private String BASE_PATH = "/api/v1/meta";
    private String USER_JOBS = "/user_jobs";
    private String STAT = "/stat";
    private String JOB_ID_QUERY = "jobId";
    private String ALL_STATS = "/all_stats";
    private String INFLUX_RANGE_MEASUREMENTS = "/stats/influx/job/range";
    private String INFLUX_JOB_MEASUREMENTS = "/stats/influx/job";
    private String INFLUX_USER_MEASUREMENTS = "/stats/influx/user";
    private String DATE = "/date";

    @Autowired
    private WebClient.Builder webClientBuilder;

    //CockroachDB data calls below

    @SneakyThrows
    public Mono<List<Long>> getAllJobIds(String userId) {
        logger.info("Querying all user jobs {}", userId);
        URI uri = UriComponentsBuilder.fromUriString(this.metaHostName)
                .path(BASE_PATH + USER_JOBS)
                .queryParam(USER_EMAIL, userId)
                .build().toUri();
        logger.info(uri.toString());
        return this.webClientBuilder.build()
                .get()
                .uri(uri)
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<List<Long>>() {
                });
    }

    @SneakyThrows
    public Mono<List<BatchJobData>> getAllStats(String userId) {
        logger.info("the userId we are querying for is {}", userId);
        URI uri = UriComponentsBuilder.fromUriString(this.metaHostName)
                .path(BASE_PATH + ALL_STATS)
                .queryParam(USER_EMAIL, userId)
                .build().toUri();
        logger.info(uri.toString());
        return this.webClientBuilder.build()
                .get()
                .uri(uri)
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<List<BatchJobData>>() {
                });
    }

    public Mono<Page<BatchJobData>> getAllStats(String userId, Integer page, Integer size, String sort, String direction) {
        URI uri = UriComponentsBuilder.fromUriString(this.metaHostName)
                .path(BASE_PATH + "/stat/page")
                .queryParam(USER_EMAIL, userId)
                .queryParam("page", page)
                .queryParam("size", size)
                .queryParam("direction", direction)
                .queryParam("sort", sort)
                .build().toUri();
        logger.info(uri.toString());
        return this.webClientBuilder.build()
                .get()
                .uri(uri)
                .retrieve()
{'fraction_non_alphanumeric': 0.11019246408240715, 'fraction_numerical': 0.0013553808620222283, 'mean_word_length': 2.7475876079228034, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '258218', 'n_tokens_mistral': 2163, 'n_tokens_neox': 2100, 'n_words': 392}