Beispiel #1
0
        static int CalculateRank(List <string[]> requests, BootstrapDemoModelBase demo, BootstrapDemoSectionModel section)
        {
            int resultRank  = 0;
            int keywordRank = 0;

            foreach (var request in requests)
            {
                int requestRank = -1;
                if (section != null && demo is BootstrapDemoPageModel && ((BootstrapDemoPageModel)demo).Sections.Count > 1 && SearchAgregator.CalculateRank(request, section.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (SearchAgregator.CalculateRank(request, demo.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (demo is BootstrapDemoGroupPageModel && SearchAgregator.CalculateRank(request, ((BootstrapDemoGroupPageModel)demo).KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (requestRank == -1 && Search.WordsExclusions.Any(re => re.Equals(request[0], SearchAgregator.DefaultStringComparison)))
                {
                    requestRank = 0;
                }
                if (requestRank > -1)
                {
                    resultRank += requestRank;
                }
                else
                {
                    return(-1);
                }
            }
            return(resultRank);
        }
Beispiel #2
0
        static int CalculateRank(List <string[]> requests, DemoPageModel demo)
        {
            int resultRank  = 0;
            int keywordRank = 0;

            foreach (var request in requests)
            {
                int requestRank = -1;
                if (SearchAgregator.CalculateRank(request, demo.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (demo.Group != null && SearchAgregator.CalculateRank(request, demo.Group.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (SearchAgregator.CalculateRank(request, demo.Product.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (requestRank == -1 && Search.WordsExclusions.Any(re => re.Equals(request[0], SearchAgregator.DefaultStringComparison)))
                {
                    requestRank = 0;
                }
                if (requestRank > -1)
                {
                    resultRank += requestRank;
                }
                else
                {
                    return(-1);
                }
            }
            return(resultRank);
        }