<commit_before>package org.lnu.is.dao.dao.entrant;

import org.lnu.is.domain.enrolment.EntrantPlace;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.List;
import java.util.stream.Collectors;

@Repository
public class EntrantPlaceDao {
    private static final String QUERY_SQL = "SELECT \n" +
            "\tCOUNT(e.id) AS enrolments_count,\n" +
            "\ts.statecount,\n" +
            "\td.name AS name, \n" +
            "\td.id AS id \n" +
            "FROM q_dc_enrolment e\n" +
            "LEFT OUTER JOIN q_ob_specoffer s ON s.id = e.specoffer_id\n" +
            "LEFT OUTER JOIN q_ob_department d ON d.id = e.department_id\n" +
            "GROUP BY d.name, d.id, s.statecount\n" +
            "ORDER BY enrolments_count DESC";

    @PersistenceContext
    private EntityManager entityManager;

    public List<EntrantPlace> getEntrantsPerPlace() {
        Query query = entityManager.createNativeQuery(QUERY_SQL);
        List<Object[]> result = query.getResultList();
        return result.stream()
                .map(arr -> new EntrantPlace(
                        Double.valueOf(arr[0].toString()) / Double.valueOf(arr[1].toString()),
                        arr[2].toString(),
                        Long.parseLong(arr[3].toString())))
                .collect(Collectors.toList());
    }<commit_msg>Fixed charts<commit_after>package org.lnu.is.dao.dao.entrant;

import org.lnu.is.domain.enrolment.EntrantPlace;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.List;
import java.util.stream.Collectors;

@Repository
public class EntrantPlaceDao {
    private static final String QUERY_SQL = "SELECT \n" +
            "\tCOUNT(e.id) AS enrolments_count,\n" +
            "\ts.statecount,\n" +
            "\td.name AS name, \n" +
            "\td.id AS id \n" +
            "FROM q_dc_enrolment e\n" +
            "LEFT OUTER JOIN q_ob_specoffer s ON s.id = e.specoffer_id\n" +
            "LEFT OUTER JOIN q_ob_department d ON d.id = e.department_id\n" +
            "GROUP BY d.name, d.id, s.statecount\n" +
            "ORDER BY enrolments_count DESC";

    @PersistenceContext
    private EntityManager entityManager;

    public List<EntrantPlace> getEntrantsPerPlace() {
        Query query = entityManager.createNativeQuery(QUERY_SQL);
        List<Object[]> result = query.getResultList();
        return result.stream()
                .map(arr -> {
                    Double stateCount = Double.valueOf(arr[1].toString());
                    return new EntrantPlace(
                            stateCount > 0.0  ? Double.valueOf(arr[0].toString()) / stateCount : 0.0,
                            arr[2].toString(),
                            Long.parseLong(arr[3].toString()));
                })
                .collect(Collectors.toList());
    }
{'fraction_non_alphanumeric': 0.11572409284079764, 'fraction_numerical': 0.003922850604772802, 'mean_word_length': 2.221052631578947, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '3959903', 'n_tokens_mistral': 942, 'n_tokens_neox': 918, 'n_words': 188}