Example #1
0
        public virtual CategoryCountData Load(string facetCode, FacetsConfig2 facetsConfig, string intervalQuery = null)
        {
            var sqlQuery       = Compile(Facets.GetByCode(facetCode), facetsConfig, intervalQuery);
            var categoryCounts = Query(sqlQuery).ToDictionary(z => z.Category ?? "(null)");

            return(new CategoryCountData {
                SqlQuery = sqlQuery,
                CategoryCounts = categoryCounts
            });
        }
        protected override string Compile(Facet facet, FacetsConfig2 facetsConfig, string payload)
        {
            // FIXME: Fix confusing args, when does facet differ from targetFacet?
            var aggregateFacet = Facets.Get(facet.AggregateFacetId);
            var targetFacet    = Facets.GetByCode(facetsConfig.TargetCode);
            var tableNames     = GetTables(facetsConfig, targetFacet, aggregateFacet);
            var facetCodes     = facetsConfig.GetFacetCodes();

            facetCodes.InsertAt(targetFacet.FacetCode, aggregateFacet.FacetCode);

            var querySetup = QuerySetupBuilder.Build(facetsConfig, aggregateFacet, tableNames, facetCodes);
            var sql        = CountSqlCompiler.Compile(querySetup, targetFacet, aggregateFacet, facet.AggregateType ?? "count");

            return(sql);
        }