<commit_before>package it.reply.orchestrator.service.commands;

import it.reply.orchestrator.dto.RankCloudProvidersMessage;
import it.reply.orchestrator.dto.ranker.CloudProviderRankerRequest;
import it.reply.orchestrator.dto.ranker.Monitoring;
import it.reply.orchestrator.dto.ranker.RankedCloudProvider;
import it.reply.orchestrator.service.CloudProviderRankerService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class GetProvidersRank extends BaseRankCloudProvidersCommand {

  @Autowired
  private CloudProviderRankerService cloudProviderRankerService;

  @Override
  protected RankCloudProvidersMessage
      customExecute(RankCloudProvidersMessage rankCloudProvidersMessage) {

    // Prepare Ranker's request
    List<Monitoring> monitoring =
        rankCloudProvidersMessage.getCloudProvidersMonitoringData().entrySet().stream()
            .map(e -> new Monitoring(e.getKey(), e.getValue())).collect(Collectors.toList());

    CloudProviderRankerRequest cprr =
        new CloudProviderRankerRequest()
            .withPreferences(rankCloudProvidersMessage.getSlamPreferences().getPreferences().get(0)
                .getPreferences())
            .withSla(rankCloudProvidersMessage.getSlamPreferences().getSla())
            .withMonitoring(monitoring);

    // FIXME Remove once the ranker is available
    // Get provider rank and save in message
    try {
      rankCloudProvidersMessage
          .setRankedCloudProviders(cloudProviderRankerService.getProviderRanking(cprr));
    } catch (Exception e2) {
      rankCloudProvidersMessage.setRankedCloudProviders(
          Arrays.asList(new RankedCloudProvider("Name1", 1, true, ""), new RankedCloudProvider(
              "STUB PROVIDER NAME -> Remove once the ranker is available", 0, true, "Error msg")));
    }

    return rankCloudProvidersMessage;
  }

}<commit_msg>Remove CPRanker stub<commit_after>package it.reply.orchestrator.service.commands;

import it.reply.orchestrator.dto.RankCloudProvidersMessage;
import it.reply.orchestrator.dto.ranker.CloudProviderRankerRequest;
import it.reply.orchestrator.dto.ranker.Monitoring;
import it.reply.orchestrator.service.CloudProviderRankerService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

@Component
public class GetProvidersRank extends BaseRankCloudProvidersCommand {

  @Autowired
  private CloudProviderRankerService cloudProviderRankerService;

  @Override
  protected RankCloudProvidersMessage
      customExecute(RankCloudProvidersMessage rankCloudProvidersMessage) {

    // Prepare Ranker's request
    List<Monitoring> monitoring =
        rankCloudProvidersMessage.getCloudProvidersMonitoringData().entrySet().stream()
            .map(e -> new Monitoring(e.getKey(), e.getValue())).collect(Collectors.toList());

    CloudProviderRankerRequest cprr =
        new CloudProviderRankerRequest()
            .withPreferences(rankCloudProvidersMessage.getSlamPreferences().getPreferences().get(0)
                .getPreferences())
            .withSla(rankCloudProvidersMessage.getSlamPreferences().getSla())
            .withMonitoring(monitoring);

    // Get provider rank and save in message
    rankCloudProvidersMessage
        .setRankedCloudProviders(cloudProviderRankerService.getProviderRanking(cprr));

    return rankCloudProvidersMessage;
  }

}
{'fraction_non_alphanumeric': 0.08723522853957637, 'fraction_numerical': 0.0016722408026755853, 'mean_word_length': 4.5816485225505446, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '6204894', 'n_tokens_mistral': 989, 'n_tokens_neox': 989, 'n_words': 161}