1
Vote

Some Pbs with Orchard 1.8 where tags have been shifted

description

 public IEnumerable<LocalizedTag> GetLocalizedTags()
        {
            var localizationBucket = new LocalizationBucket(_cultureManager, _workContextAccessor);
            if (localizationBucket.CurrentCulture == null || localizationBucket.CurrentCulture.Id == 0) return new List<LocalizedTag>();

            var cacheKey = "RM.Localization.TagCloud." + localizationBucket.CurrentCulture.Culture;

            return _cacheManager.Get(cacheKey, ctx =>
            {
                ctx.Monitor(_signals.When(_localizedTagcloudTagsChanged));
                var tags = _contentManager
                    .Query<TagsPart, TagsPartRecord>(VersionOptions.Published)
                    .List()
                    .Select(x => x.As<LocalizationPart>())
                    .Where(x => x.Culture == null && localizationBucket.IsCurrentCultureDefault || x.Culture != null && x.Culture.Id == localizationBucket.CurrentCulture.Id)
                    .Select(x => x.As<TagsPart>())
                    .SelectMany(x => x.CurrentTags)
                    //.GroupBy(x => x.TagName) CS 1/5/14
                    .GroupBy(x => x)
                    .Select(x => new LocalizedTag { TagName = x.Key, Count = x.Count() }).ToList();

                if (tags.Any())
                {
                    var maxCount = tags.Max(tc => tc.Count);
                    var minCount = tags.Min(tc => tc.Count);
                    var delta = maxCount - minCount;
                    if (delta != 0)
                    {
                        foreach (var tag in tags)
                        {
                            tag.Bucket = (tag.Count - minCount) * (Buckets - 1) / delta + 1;
                        }
                    }
                }
                return tags;
            });

comments