<commit_before>package ch.squix.extraleague.rest.ranking;

import static com.googlecode.objectify.ObjectifyService.ofy;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.logging.Logger;

import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

import ch.squix.extraleague.model.match.Match;
import ch.squix.extraleague.model.ranking.EternalRanking;
import ch.squix.extraleague.model.ranking.Ranking;
import ch.squix.extraleague.model.ranking.RankingService;

import com.google.appengine.api.NamespaceManager;
import com.google.common.base.Strings;

public class RankingResource extends ServerResource {
	
	private static final Logger log = Logger.getLogger(RankingResource.class.getName());

	
	@Get(value = "json")
	public List<RankingDto> execute() throws UnsupportedEncodingException {
		String rankingType = getQuery().getValues("type");
		if (Strings.isNullOrEmpty(rankingType) || "All".equals(rankingType)) {
			log.info("Requesting ranking for namespace: " + NamespaceManager.get());
			Ranking ranking = ofy().load().type(Ranking.class).order("-createdDate").first().now();
			if (ranking == null) {
				return new ArrayList<>();
			}
			
			return RankingDtoMapper.convertToDto(ranking);
		} else if ("eternal".equals(rankingType)) {
			EternalRanking eternalRanking = ofy().load().type(EternalRanking.class).first().now();
			if (eternalRanking == null) {
				return new ArrayList<>();
			}
			return RankingDtoMapper.convertToDto(eternalRanking);
		} else if ("tag".equals(rankingType)) {<commit_msg>Update RankingResource.java<commit_after>package ch.squix.extraleague.rest.ranking;

import static com.googlecode.objectify.ObjectifyService.ofy;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.logging.Logger;

import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

import ch.squix.extraleague.model.match.Match;
import ch.squix.extraleague.model.ranking.EternalRanking;
import ch.squix.extraleague.model.ranking.Ranking;
import ch.squix.extraleague.model.ranking.RankingService;

import com.google.appengine.api.NamespaceManager;
import com.google.common.base.Strings;

public class RankingResource extends ServerResource {
	
	private static final Logger log = Logger.getLogger(RankingResource.class.getName());

	
	@Get(value = "json")
	public List<RankingDto> execute() throws UnsupportedEncodingException {
		String rankingType = getQuery().getValues("type");
		if (Strings.isNullOrEmpty(rankingType) || "All".equals(rankingType)) {
			log.info("Requesting ranking for namespace: " + NamespaceManager.get());
			Ranking ranking = ofy().load().type(Ranking.class).order("-createdDate").first().now();
			if (ranking == null) {
				return new ArrayList<>();
			}
			
			return RankingDtoMapper.convertToDto(ranking);
		} else if ("Eternal".equals(rankingType)) {
			EternalRanking eternalRanking = ofy().load().type(EternalRanking.class).first().now();
			if (eternalRanking == null) {
				return new ArrayList<>();
			}
			return RankingDtoMapper.convertToDto(eternalRanking);
		} else if ("tag".equals(rankingType)) {
{'fraction_non_alphanumeric': 0.13098159509202453, 'fraction_numerical': 0.0, 'mean_word_length': 5.587878787878788, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '16991', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1001, 'n_words': 177}