/// <summary>
        /// Removes invalid selections e.g. hidden selections still being sent from the client.
        /// The client keep them since they can be visible when the filters changes.
        /// This is only applicable for discrete facets (range facet selection are always visible)
        /// </summary>
        /// <param name="facetsConfig"></param>
        /// <returns></returns>
        public FacetsConfig2 Update(FacetsConfig2 facetsConfig)
        {
            foreach (string facetCode in facetsConfig.GetFacetCodes())
            {
                var config = facetsConfig.GetConfig(facetCode);

                if (config.Facet.FacetTypeId != EFacetType.Discrete || config.Picks.Count == 0)
                {
                    continue;
                }

                if (!config.HasPicks())
                {
                    continue;
                }

                config.Picks = QueryProxy.QueryRows(
                    PicksCompiler.Compile(
                        QuerySetupBuilder.Build(facetsConfig, config.Facet, null, null),
                        config.GetIntegerPickValues()
                        ),
                    x => new FacetConfigPick(EPickType.discrete, x.GetString(0), x.GetString(1))
                    );
            }
            return(facetsConfig);
        }
Exemplo n.º 2
0
        protected override FacetContent.IntervalQueryInfo CompileIntervalQuery(FacetsConfig2 facetsConfig, string facetCode, int default_interval_count = 120)
        {
            var facetConfig = facetsConfig.GetConfig(facetCode);
            var fullExtent  = OuterBoundExtentService.GetExtent(facetConfig, default_interval_count);
            var pickExtent  = GetPickExtent(facetConfig, default_interval_count) ?? fullExtent;

            var(lower, upper, interval_count) = (pickExtent.Lower, pickExtent.Upper, pickExtent.Count);

            int interval = Math.Max((int)Math.Floor((upper - lower) / interval_count), 1);

            string sql = RangeIntervalSqlCompiler.Compile(interval, (int)lower, (int)upper, interval_count);

            return(new RangeIntervalQueryInfo
            {
                Count = interval,
                Query = sql,
                FullExtent = fullExtent
            });
        }