<commit_before>package attackontinytim.barquest.Database;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by <NAME> on 4/17/2017.
 */

public class ConsumableRepo {
    private static final String TABLE_CONSUMABLE= "Consumable";
    // Consumable Table Columns names
    private static final String KEY_NAME = "Name";
    private static final String KEY_EFFECT = "Effect";
    private static final String KEY_EFFECTSTRENGTH = "EffectStrength";
    private static final String KEY_VALUE = "Value";


    public static String getTableName(){
        return TABLE_CONSUMABLE;
    }

    public static String createTable(){
        return "CREATE TABLE " + TABLE_CONSUMABLE + "("
                + KEY_NAME + " TEXT PRIMARY KEY,"
                + KEY_EFFECT + " TEXT, "
                + KEY_EFFECTSTRENGTH + " INT,"
                + KEY_VALUE + " DOUBLE)";
    }


    /**
     * Function that adds an consumable to the Consumable table in the database
     * @param consumable An consumable object to add to the database
     */
    public static void addConsumable(ConsumableItem consumable) {
        SQLiteDatabase db = DatabaseManager.getInstance().openDatabase();
        ContentValues values = new ContentValues();
        values.put(KEY_NAME , consumable.getName());
        values.put(KEY_EFFECT , consumable.getEffect());
        values.put(KEY_EFFECTSTRENGTH , consumable.getEffectStrength());
        values.put(KEY_VALUE , consumable.getValue());

        // Inserting Row
        db.insert(TABLE_CONSUMABLE, null, values);
        DatabaseManager.getInstance().closeDatabase(); // Closing database connection
    }

    /**
     * Returns an consumable object with the given name
     * @param name Name of the consumable
     * @return Consumable object
     */
    public static ConsumableItem getConsumableByName(String name) {
        SQLiteDatabase db = DatabaseManager.getInstance().openDatabase();
        Cursor cursor = db.query(TABLE_CONSUMABLE, new String[] {
                        KEY_NAME ,
                        KEY_EFFECT ,
                        KEY_EFFECTSTRENGTH ,
                        KEY_VALUE}, KEY_NAME + "=?",
                new String[] { String.valueOf(name) }, null, null, null, null);<commit_msg>Reordered Query statement in getConsumableByName that was causing issues with the unpacking of values.<commit_after>package attackontinytim.barquest.Database;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by <NAME> on 4/17/2017.
 */

public class ConsumableRepo {
    private static final String TABLE_CONSUMABLE= "Consumable";
    // Consumable Table Columns names
    private static final String KEY_NAME = "Name";
    private static final String KEY_EFFECT = "Effect";
    private static final String KEY_EFFECTSTRENGTH = "EffectStrength";
    private static final String KEY_VALUE = "Value";


    public static String getTableName(){
        return TABLE_CONSUMABLE;
    }

    public static String createTable(){
        return "CREATE TABLE " + TABLE_CONSUMABLE + "("
                + KEY_NAME + " TEXT PRIMARY KEY,"
                + KEY_EFFECT + " TEXT, "
                + KEY_EFFECTSTRENGTH + " INT,"
                + KEY_VALUE + " DOUBLE)";
    }


    /**
     * Function that adds an consumable to the Consumable table in the database
     * @param consumable An consumable object to add to the database
     */
    public static void addConsumable(ConsumableItem consumable) {
        SQLiteDatabase db = DatabaseManager.getInstance().openDatabase();
        ContentValues values = new ContentValues();
        values.put(KEY_NAME , consumable.getName());
        values.put(KEY_EFFECT , consumable.getEffect());
        values.put(KEY_EFFECTSTRENGTH , consumable.getEffectStrength());
        values.put(KEY_VALUE , consumable.getValue());

        // Inserting Row
        db.insert(TABLE_CONSUMABLE, null, values);
        DatabaseManager.getInstance().closeDatabase(); // Closing database connection
    }

    /**
     * Returns an consumable object with the given name
     * @param name Name of the consumable
     * @return Consumable object
     */
    public static ConsumableItem getConsumableByName(String name) {
        SQLiteDatabase db = DatabaseManager.getInstance().openDatabase();
        Cursor cursor = db.query(TABLE_CONSUMABLE, new String[] {
                        KEY_EFFECT ,
                        KEY_EFFECTSTRENGTH ,
                        KEY_NAME,
                        KEY_VALUE}, KEY_NAME + "=?",
                new String[] { String.valueOf(name) }, null, null, null, null);
{'fraction_non_alphanumeric': 0.09002884219200659, 'fraction_numerical': 0.00288421920065925, 'mean_word_length': 2.6339820359281436, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7591320', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1280, 'n_words': 354}