<commit_before>package com.xtech.sunshine_tutorial;

import android.annotation.TargetApi;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.util.Log;

public class WeatherProvider extends ContentProvider {
    // The URI Matcher used by this content provider.
    private static final UriMatcher uriMatcher = buildUriMatcher();
    private static final SQLiteQueryBuilder weatherByLocationQueryBuilder;
    private WeatherDbHelper dbHelper;
    private SQLiteDatabase db;

    static final int WEATHER = 100;
    static final int WEATHER_WITH_LOCATION = 101;
    static final int WEATHER_WITH_LOCATION_AND_DATE = 102;
    static final int LOCATION = 300;

    public WeatherProvider(){
        dbHelper = new WeatherDbHelper(getContext());
    }


    static{
        weatherByLocationQueryBuilder = new SQLiteQueryBuilder();

        //This is an inner join which looks like
        //weather INNER JOIN location ON weather.location_id = location._id
        weatherByLocationQueryBuilder.setTables(
                WeatherContract.WeatherEntry.TABLE_NAME + " INNER JOIN " +
                        WeatherContract.LocationEntry.TABLE_NAME +
                        " ON " + WeatherContract.WeatherEntry.TABLE_NAME +
                        "." + WeatherContract.WeatherEntry.COL_LOC_KEY +
                        " = " + WeatherContract.LocationEntry.TABLE_NAME +
                        "." + WeatherContract.LocationEntry._ID);
    }

    private static final String locationSelection =
            WeatherContract.LocationEntry.TABLE_NAME+
                    "." + WeatherContract.LocationEntry.COL_CITY_NAME + " = ? ";

    //location.location_setting = ? AND date >= ?
    private static final String locationWithStartDateSelection =
            WeatherContract.LocationEntry.TABLE_NAME+
                    "." + WeatherContract.LocationEntry.COL_CITY_NAME + " = ? AND " +
                    WeatherContract.WeatherEntry.COL_DATE + " >= ? ";

    private static final String locationAndDaySelection =
            WeatherContract.LocationEntry.TABLE_NAME +
                    "." + WeatherContract.LocationEntry.COL_CITY_NAME + " = ? AND " +
                    WeatherContract.WeatherEntry.COL_DATE + " = ? ";

    private Cursor getWeatherByLocation(Uri uri, String[] projection, String sortOrder) {
        String locationSetting = WeatherContract.WeatherEntry.getLocationFromUri(uri);
        String startDate = WeatherContract.WeatherEntry.getStartDateFromUri(uri);

        String[] selectionArgs;
        String selection;

        if (startDate == null) {
            selection = locationSelection;
            selectionArgs = new String[]{locationSetting};
        } else {
            selectionArgs = new String[]{locationSetting, startDate};
            selection = locationWithStartDateSelection;
        }

        return weatherByLocationQueryBuilder.query(dbHelper.getReadableDatabase(),
                projection,
                selection,
                selectionArgs,
                null,
                null,
                sortOrder
        );
    }<commit_msg>Fixed database selection args<commit_after>package com.xtech.sunshine_tutorial;

import android.annotation.TargetApi;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.util.Log;

public class WeatherProvider extends ContentProvider {
    // The URI Matcher used by this content provider.
    private static final UriMatcher uriMatcher = buildUriMatcher();
    private static final SQLiteQueryBuilder weatherByLocationQueryBuilder;
    private WeatherDbHelper dbHelper;
    private SQLiteDatabase db;

    static final int WEATHER = 100;
    static final int WEATHER_WITH_LOCATION = 101;
    static final int WEATHER_WITH_LOCATION_AND_DATE = 102;
    static final int LOCATION = 300;

    public WeatherProvider(){
        dbHelper = new WeatherDbHelper(getContext());
    }


    static{
        weatherByLocationQueryBuilder = new SQLiteQueryBuilder();

        //This is an inner join which looks like
        //weather INNER JOIN location ON weather.location_id = location._id
        weatherByLocationQueryBuilder.setTables(
                WeatherContract.WeatherEntry.TABLE_NAME + " INNER JOIN " +
                        WeatherContract.LocationEntry.TABLE_NAME +
                        " ON " + WeatherContract.WeatherEntry.TABLE_NAME +
                        "." + WeatherContract.WeatherEntry.COL_LOC_KEY +
                        " = " + WeatherContract.LocationEntry.TABLE_NAME +
                        "." + WeatherContract.LocationEntry._ID);
    }

    private static final String locationSelection =
            WeatherContract.LocationEntry.TABLE_NAME+
                    "." + WeatherContract.LocationEntry.COL_CITY_NAME + " = ? ";

    //location.location_setting = ? AND date >= ?
    private static final String locationWithStartDateSelection =
            WeatherContract.LocationEntry.TABLE_NAME+
                    "." + WeatherContract.LocationEntry.COL_CITY_NAME + " = ? AND " +
                    WeatherContract.WeatherEntry.COL_DATE + " >= ? ";

    private static final String locationAndDaySelection =
            WeatherContract.LocationEntry.TABLE_NAME +
                    "." + WeatherContract.LocationEntry.COL_CITY_NAME + " = ? AND " +
                    WeatherContract.WeatherEntry.COL_DATE + " = ? ";

    private Cursor getWeatherByLocation(Uri uri, String[] projection, String sortOrder) {
        String locationSetting = WeatherContract.WeatherEntry.getLocationFromUri(uri);

        String[] selectionArgs = new String[]{locationSetting};

        return weatherByLocationQueryBuilder.query(dbHelper.getReadableDatabase(),
                projection,
                locationSelection,
                selectionArgs,
                null,
                null,
                sortOrder
        );
    }
{'fraction_non_alphanumeric': 0.07519392116511002, 'fraction_numerical': 0.0037992718062371377, 'mean_word_length': 2.5375139977603585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6541126', 'n_tokens_mistral': 1623, 'n_tokens_neox': 1497, 'n_words': 331}