<commit_before>﻿using MySqlConnector;
using Stankins.Interfaces;
using StankinsCommon;
using StankinsObjects;
using StankinsReceiverDB;
using System;
using System.Data.Common;
using System.Threading.Tasks;

namespace Stankins.MariaDB
{
    public class ReceiveMetadataFromDatabaseMariaDB : DatabaseReceiver
    {
        public ReceiveMetadataFromDatabaseMariaDB(CtorDictionary dataNeeded) : base(new CtorDictionary(dataNeeded)
            .AddMyValue(
                nameof(connectionType), typeof(MySqlConnection).AssemblyQualifiedName)
            )
        {
            this.Name = nameof(ReceiveMetadataFromDatabaseMariaDB);
        }
        public ReceiveMetadataFromDatabaseMariaDB(string connectionString) : this(
            new CtorDictionary(){
              {nameof(  connectionString),connectionString }
            })
        {
            this.Name = nameof(ReceiveMetadataFromDatabaseMariaDB);
        }


        public override async Task<IDataToSent> TransformData(IDataToSent receiveData)
        {
            receiveData ??= new DataToSentTable();
            var b = new MySqlConnectionStringBuilder(base.connectionString);
            var tablesString = $"select Concat(Table_SCHEMA,'.' ,TABLE_NAME) as id , TABLE_NAME  as name from  information_schema.TABLES where TABLE_SCHEMA='{b.Database}'";
            var newTables = FromSql(tablesString, "tables");

            var cols = $@"select Concat(Table_SCHEMA,'.' ,TABLE_NAME,'.',COLUMN_NAME) as id, 
COLUMN_NAME as name, Concat(Table_SCHEMA, '.', TABLE_NAME) as tableId
from information_schema.COLUMNS where TABLE_SCHEMA = '{b.Database}'
";

            var newCols = FromSql(cols, "columns");
            var rels = $@"select CONCAT(Table_SCHEMA,'.' ,TABLE_NAME,'.',COLUMN_NAME,'.',CONSTRAINT_NAME) as id<commit_msg>type in mariadb<commit_after>﻿using MySqlConnector;
using Stankins.Interfaces;
using StankinsCommon;
using StankinsObjects;
using StankinsReceiverDB;
using System;
using System.Data.Common;
using System.Threading.Tasks;

namespace Stankins.MariaDB
{
    public class ReceiveMetadataFromDatabaseMariaDB : DatabaseReceiver
    {
        public ReceiveMetadataFromDatabaseMariaDB(CtorDictionary dataNeeded) : base(new CtorDictionary(dataNeeded)
            .AddMyValue(
                nameof(connectionType), typeof(MySqlConnection).AssemblyQualifiedName)
            )
        {
            this.Name = nameof(ReceiveMetadataFromDatabaseMariaDB);
        }
        public ReceiveMetadataFromDatabaseMariaDB(string connectionString) : this(
            new CtorDictionary(){
              {nameof(  connectionString),connectionString }
            })
        {
            this.Name = nameof(ReceiveMetadataFromDatabaseMariaDB);
        }


        public override async Task<IDataToSent> TransformData(IDataToSent receiveData)
        {
            receiveData ??= new DataToSentTable();
            var b = new MySqlConnectionStringBuilder(base.connectionString);
            var tablesString = $"select Concat(Table_SCHEMA,'.' ,TABLE_NAME) as id , TABLE_NAME  as name from  information_schema.TABLES where TABLE_SCHEMA='{b.Database}'";
            var newTables = FromSql(tablesString, "tables");

            var cols = $@"select Concat(Table_SCHEMA,'.' ,TABLE_NAME,'.',COLUMN_NAME) as id, 
COLUMN_NAME as name, Concat(Table_SCHEMA, '.', TABLE_NAME) as tableId
, COLUMN_TYPE as type
from information_schema.COLUMNS where TABLE_SCHEMA = '{b.Database}'
";

            var newCols = FromSql(cols, "columns");
            var rels = $@"select CONCAT(Table_SCHEMA,'.' ,TABLE_NAME,'.',COLUMN_NAME,'.',CONSTRAINT_NAME) as id
{'fraction_non_alphanumeric': 0.09430309734513274, 'fraction_numerical': 0.0, 'mean_word_length': 3.300832342449465, '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': '1797466', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1018, 'n_words': 210}