<commit_before>package org.mousephenotype.cda.solr.service;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.mousephenotype.cda.solr.SolrUtils;
import org.mousephenotype.cda.solr.service.dto.PhenodigmDTO;
import org.mousephenotype.cda.utilities.HttpProxy;
import org.mousephenotype.cda.web.WebStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;

@Service
public class PhenodigmService implements WebStatus {

	private final Logger logger = LoggerFactory.getLogger(PhenodigmService.class);
	private final Double MIN_RAW_SCORE_CUTOFF = 1.97;

	@Autowired
	@Qualifier("phenodigmCore")
	private SolrClient solr;

	/**
	 * Get the number of unique disease associations from the phenodigm core
	 *
	 * @return a count of the number of disease associations or 0 if there was an error and a log entry will be made
	 */
	public Integer getDiseaseAssociationCount() {

		Integer nGroups = null;

		try {
			SolrQuery q = new SolrQuery();

			q.setQuery("*:*")
					.setRows(0)
					.addFilterQuery(PhenodigmDTO.TYPE + ":disease_model_association")

					.set("group", true)
					.set("group.ngroups", true)
					.set("group.field", PhenodigmDTO.MODEL_ID);

			nGroups = solr.query(q).getGroupResponse().getValues().get(0).getNGroups();
		} catch (IOException | SolrServerException | HttpSolrClient.RemoteSolrException e) {
			logger.error("\n\nERROR getDiseaseAssociationCount: Could not get disease association count\n\n", e);
		}

		return nGroups;

	}

	@Override
	public long getWebStatus() throws SolrServerException, IOException {

		SolrQuery query = new SolrQuery();

		query.setQuery("*:*").setRows(0);

		//System.out.println("SOLR URL WAS " + SolrUtils.getBaseURL(solr) + "/select?" + query);

		QueryResponse response = solr.query(query);<commit_msg>Updated PhenodigmService.getDiseaseAssociationCount() to replace the old field disease_model_association with the new field disease_model_summary.<commit_after>package org.mousephenotype.cda.solr.service;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.mousephenotype.cda.solr.SolrUtils;
import org.mousephenotype.cda.solr.service.dto.PhenodigmDTO;
import org.mousephenotype.cda.utilities.HttpProxy;
import org.mousephenotype.cda.web.WebStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;

@Service
public class PhenodigmService implements WebStatus {

	private final Logger logger = LoggerFactory.getLogger(PhenodigmService.class);
	private final Double MIN_RAW_SCORE_CUTOFF = 1.97;

	@Autowired
	@Qualifier("phenodigmCore")
	private SolrClient solr;

	/**
	 * Get the number of unique disease associations from the phenodigm core
	 *
	 * @return a count of the number of disease associations or 0 if there was an error and a log entry will be made
	 */
	public Integer getDiseaseAssociationCount() {

		Integer nGroups = null;

		try {
			SolrQuery q = new SolrQuery();

			q.setQuery("*:*")
					.setRows(0)
					.addFilterQuery(PhenodigmDTO.TYPE + ":disease_model_summary")

					.set("group", true)
					.set("group.ngroups", true)
					.set("group.field", PhenodigmDTO.MODEL_ID);

			nGroups = solr.query(q).getGroupResponse().getValues().get(0).getNGroups();
		} catch (IOException | SolrServerException | HttpSolrClient.RemoteSolrException e) {
			logger.error("\n\nERROR getDiseaseAssociationCount: Could not get disease association count\n\n", e);
		}

		return nGroups;

	}

	@Override
	public long getWebStatus() throws SolrServerException, IOException {

		SolrQuery query = new SolrQuery();

		query.setQuery("*:*").setRows(0);

		//System.out.println("SOLR URL WAS " + SolrUtils.getBaseURL(solr) + "/select?" + query);

		QueryResponse response = solr.query(query);
{'fraction_non_alphanumeric': 0.11150852093414686, 'fraction_numerical': 0.003787081843046497, 'mean_word_length': 5.071519795657727, 'pattern_counts': {'":': 2, '<': 3, '<?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': '1093645', 'n_tokens_mistral': 1697, 'n_tokens_neox': 1524, 'n_words': 321}