<commit_before>package com.gurkensalat.osm.mosques.repository;

import com.gurkensalat.osm.mosques.entity.OsmMosquePlace;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import javax.transaction.Transactional;
import java.util.List;

@RepositoryRestResource(collectionResourceRel = "ditibPlace", path = "ditibPlace")
public interface OsmMosquePlaceRepository extends PagingAndSortingRepository<OsmMosquePlace, Long>
{
    List<OsmMosquePlace> findByKey(@Param("key") String key);

    List<OsmMosquePlace> findByName(@Param("name") String name);

    @Query("SELECT p FROM OsmMosquePlace p WHERE :min_lon <= p.lon and p.lon < :max_lon and :min_lat <= p.lat and p.lat <= :max_lat")
    List<OsmMosquePlace> findByBbox(@Param("min_lon") double minLongitude,
                                    @Param("min_lat") double minLatitude,
                                    @Param("max_lon") double maxLongitude,
                                    @Param("max_lat") double maxLatitude);

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set valid = false")
    void invalidateAll();

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set valid = false where ADDR_COUNTRY = :addr_country")
    void invalidateByCountryCode(@Param("addr_country") String countryCode);

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set valid = false where ADDR_COUNTRY_DATAFILE = :addr_country")
    void invalidateByCountryCodeFromDatafile(@Param("addr_country") String countryCode);

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set valid = false where ADDR_COUNTRY_OSM = :addr_country")
    void invalidateByCountryCodeFromOSM(@Param("addr_country") String countryCode);

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set valid = false where ADDR_COUNTRY_GEOCODING = :addr_country")
    void invalidateByCountryCodeFromGeocoding(@Param("addr_country") String countryCode);

    @Modifying
    @Transactional
    @Query("delete from OsmMosquePlace where valid = false")
    void deleteAllInvalid();

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set ADDR_COUNTRY_GEOCODING = '' where ADDR_COUNTRY_GEOCODING is null")
    void emptyIfNullCountryCodeFromGeocoding();
}
<commit_msg>Methods to find places to reverse geocode country code for<commit_after>package com.gurkensalat.osm.mosques.repository;

import com.gurkensalat.osm.mosques.entity.OsmMosquePlace;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import javax.transaction.Transactional;
import java.util.List;

@RepositoryRestResource(collectionResourceRel = "ditibPlace", path = "ditibPlace")
public interface OsmMosquePlaceRepository extends PagingAndSortingRepository<OsmMosquePlace, Long>
{
    List<OsmMosquePlace> findByKey(@Param("key") String key);

    List<OsmMosquePlace> findByName(@Param("name") String name);

    @Query("SELECT p FROM OsmMosquePlace p WHERE :min_lon <= p.lon and p.lon < :max_lon and :min_lat <= p.lat and p.lat <= :max_lat")
    List<OsmMosquePlace> findByBbox(@Param("min_lon") double minLongitude,
                                    @Param("min_lat") double minLatitude,
                                    @Param("max_lon") double maxLongitude,
                                    @Param("max_lat") double maxLatitude);

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set valid = false")
    void invalidateAll();

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set valid = false where ADDR_COUNTRY = :addr_country")
    void invalidateByCountryCode(@Param("addr_country") String countryCode);

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set valid = false where ADDR_COUNTRY_DATAFILE = :addr_country")
    void invalidateByCountryCodeFromDatafile(@Param("addr_country") String countryCode);

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set valid = false where ADDR_COUNTRY_OSM = :addr_country")
    void invalidateByCountryCodeFromOSM(@Param("addr_country") String countryCode);

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set valid = false where ADDR_COUNTRY_GEOCODING = :addr_country")
    void invalidateByCountryCodeFromGeocoding(@Param("addr_country") String countryCode);

    @Modifying
    @Transactional
    @Query("delete from OsmMosquePlace where valid = false")
    void deleteAllInvalid();

    @Modifying
    @Transactional
    @Query("update OsmMosquePlace set ADDR_COUNTRY_GEOCODING = '' where ADDR_COUNTRY_GEOCODING is null")
    void emptyIfNullCountryCodeFromGeocoding();

    @Query("SELECT p FROM OsmMosquePlace p WHERE ADDR_COUNTRY is null and p.countryFromGeocoding = '' order by p.lastGeocodeAttempt, p.key")
    List<OsmMosquePlace> reverseCountryGeocodingCandidates(Pageable pageable);

    @Query("SELECT p FROM OsmMosquePlace p WHERE :min_lon <= p.lon and p.lon < :max_lon and :min_lat <= p.lat and p.lat <= :max_lat and ADDR_COUNTRY is null and p.countryFromGeocoding = '' order by p.lastGeocodeAttempt, p.key")
    List<OsmMosquePlace> reverseCountryGeocodingCandidates(Pageable pageable,
                                                           @Param("min_lon") double minLongitude,
                                                           @Param("min_lat") double minLatitude,
                                                           @Param("max_lon") double maxLongitude,
                                                           @Param("max_lat") double maxLatitude);

}

{'fraction_non_alphanumeric': 0.09126594700686948, 'fraction_numerical': 0.0, 'mean_word_length': 3.796078431372549, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1095384', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1771, 'n_words': 377}