<commit_before>﻿using EDDiscovery.DB;
using EDDiscovery.EliteDangerous;
using EDDiscovery.EliteDangerous.JournalEvents;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EDDiscovery2.DB
{
    public class MaterialCommodities
    {
        public long id { get; set; }
        public string category { get; set; }                // either Commodity, or one of the Category types from the MaterialCollected type.
        public string name { get; set; }                    // name of it
        public string type { get; set; }                    // and its type, for materials its rarity, for commodities its group ("Metals" etc).

        // Not in DB

        public int count { get; set; }
        public double price { get; set; }

        public static string CommodityCategory = "Commodity";
        public static string MaterialRawCategory = "Raw";

        // Helpers

        public MaterialCommodities()
        {
        }

        public MaterialCommodities(MaterialCommodities c)     // copy constructor, ensure a different copy of this
        {
            id = c.id;
            category = c.category;
            name = String.Copy(c.name);
            type = String.Copy(c.type);
            count = c.count;
            price = c.price;
        }

        public MaterialCommodities(string cs, string n, string t, int c = 0 , int p = 0)
        {
            category = cs;
            name = n;
            type = t;
            count = c;
            price = p;
        }

        public bool Add()
        {
            using (SQLiteConnectionUser cn = new SQLiteConnectionUser())      // open connection..
            {
                bool ret = Add(cn);
                return ret;
            }
        }

        private bool Add(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("Insert into MaterialsCommodities (Category,Name,Type) values (@category,@name,@type)"))
            {
                cmd.AddParameterWithValue("@category", category);
                cmd.AddParameterWithValue("@name", name);
                cmd.AddParameterWithValue("@type", type);
                SQLiteDBClass.SQLNonQueryText(cn, cmd);

                using (DbCommand cmd2 = cn.CreateCommand("Select Max(id) as id from Bookmarks"))
                {
                    id = (long)SQLiteDBClass.SQLScalar(cn, cmd2);
                }
                return true;
            }
        }

        public bool Update()
        {
            using (SQLiteConnectionUser cn = new SQLiteConnectionUser())
            {
                return Update(cn);
            }<commit_msg>Fix stupid copy/paste error in materialcommodities<commit_after>﻿using EDDiscovery.DB;
using EDDiscovery.EliteDangerous;
using EDDiscovery.EliteDangerous.JournalEvents;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EDDiscovery2.DB
{
    public class MaterialCommodities
    {
        public long id { get; set; }
        public string category { get; set; }                // either Commodity, or one of the Category types from the MaterialCollected type.
        public string name { get; set; }                    // name of it
        public string type { get; set; }                    // and its type, for materials its rarity, for commodities its group ("Metals" etc).

        // Not in DB

        public int count { get; set; }
        public double price { get; set; }

        public static string CommodityCategory = "Commodity";
        public static string MaterialRawCategory = "Raw";

        // Helpers

        public MaterialCommodities()
        {
        }

        public MaterialCommodities(MaterialCommodities c)     // copy constructor, ensure a different copy of this
        {
            id = c.id;
            category = c.category;
            name = String.Copy(c.name);
            type = String.Copy(c.type);
            count = c.count;
            price = c.price;
        }

        public MaterialCommodities(string cs, string n, string t, int c = 0 , int p = 0)
        {
            category = cs;
            name = n;
            type = t;
            count = c;
            price = p;
        }

        public bool Add()
        {
            using (SQLiteConnectionUser cn = new SQLiteConnectionUser())      // open connection..
            {
                bool ret = Add(cn);
                return ret;
            }
        }

        private bool Add(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("Insert into MaterialsCommodities (Category,Name,Type) values (@category,@name,@type)"))
            {
                cmd.AddParameterWithValue("@category", category);
                cmd.AddParameterWithValue("@name", name);
                cmd.AddParameterWithValue("@type", type);
                SQLiteDBClass.SQLNonQueryText(cn, cmd);

                using (DbCommand cmd2 = cn.CreateCommand("Select Max(id) as id from MaterialsCommodities"))
                {
                    id = (long)SQLiteDBClass.SQLScalar(cn, cmd2);
                }
                return true;
            }
        }

        public bool Update()
        {
            using (SQLiteConnectionUser cn = new SQLiteConnectionUser())
            {
                return Update(cn);
            }
{'fraction_non_alphanumeric': 0.08826714801444044, 'fraction_numerical': 0.0018050541516245488, 'mean_word_length': 1.6373155640171346, 'pattern_counts': {'":': 0, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1671661', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1405, 'n_words': 415}