<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using NBi.Core.Analysis.Request;

namespace NBi.Core.Analysis.Metadata.Adomd
{
    internal class MeasureDiscoveryCommand : MeasureGroupDiscoveryCommand
    {
        public MeasureDiscoveryCommand(string connectionString)
            : base(connectionString)
        {

        }

        public new virtual MeasureCollection List(IEnumerable<IFilter> filters)
        {
            var measures = new MeasureCollection();

            var rows = Discover(filters);
            foreach (var row in rows)
                measures.Add(row.UniqueName, row.Caption, row.DisplayFolder);

            return measures;
        }

        internal new IEnumerable<MeasureRow> Discover(IEnumerable<IFilter> filters)
        {
            var measures = new List<MeasureRow>();
            
            Inform("Investigating measure-groups");

            using (var cmd = CreateCommand())
            {
                var adomdFiltering = Build(filters);
                cmd.CommandText = string.Format("SELECT * FROM $system.mdschema_measures WHERE MEASURE_IS_VISIBLE and LEN(MEASUREGROUP_NAME)>0{0}", adomdFiltering);
                var rdr = ExecuteReader(cmd);

                while (rdr.Read())
                {
                    var row = MeasureRow.Load(rdr);
                    if (row != null)
                        measures.Add(row);
                }
            }

            return measures;
        }

        public override IEnumerable<IField> Execute()
        {
            var values = List(Filters);
            return values.Values.ToArray();
        }<commit_msg>Fix Information message when investing measures<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using NBi.Core.Analysis.Request;

namespace NBi.Core.Analysis.Metadata.Adomd
{
    internal class MeasureDiscoveryCommand : MeasureGroupDiscoveryCommand
    {
        public MeasureDiscoveryCommand(string connectionString)
            : base(connectionString)
        {

        }

        public new virtual MeasureCollection List(IEnumerable<IFilter> filters)
        {
            var measures = new MeasureCollection();

            var rows = Discover(filters);
            foreach (var row in rows)
                measures.Add(row.UniqueName, row.Caption, row.DisplayFolder);

            return measures;
        }

        internal new IEnumerable<MeasureRow> Discover(IEnumerable<IFilter> filters)
        {
            var measures = new List<MeasureRow>();
            
            Inform("Investigating measures");

            using (var cmd = CreateCommand())
            {
                var adomdFiltering = Build(filters);
                cmd.CommandText = string.Format("SELECT * FROM $system.mdschema_measures WHERE MEASURE_IS_VISIBLE and LEN(MEASUREGROUP_NAME)>0{0}", adomdFiltering);
                var rdr = ExecuteReader(cmd);

                while (rdr.Read())
                {
                    var row = MeasureRow.Load(rdr);
                    if (row != null)
                        measures.Add(row);
                }
            }

            return measures;
        }

        public override IEnumerable<IField> Execute()
        {
            var values = List(Filters);
            return values.Values.ToArray();
        }
{'fraction_non_alphanumeric': 0.08402612826603326, 'fraction_numerical': 0.0011876484560570072, 'mean_word_length': 1.800498753117207, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '825749', 'n_tokens_mistral': 878, 'n_tokens_neox': 814, 'n_words': 187}