<commit_before>using System;
using System.Linq;
using System.Web.Routing;
using JetBrains.Annotations;
using NGM.Forum.Extensions;
using NGM.Forum.Models;
using NGM.Forum.Services;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Models;
using Orchard.Data;

namespace NGM.Forum.Handlers {
    [UsedImplicitly]
    public class ThreadPartHandler : ContentHandler {
        private readonly IPostService _postService;
        private readonly IThreadService _threadService;
        private readonly IForumService _forumService;

        public ThreadPartHandler(IRepository<ThreadPartRecord> repository, IPostService postService, IThreadService threadService, IForumService forumService, RequestContext requestContext) {
            _postService = postService;
            _threadService = threadService;
            _forumService = forumService;

            Filters.Add(StorageFilter.For(repository));

            OnGetDisplayShape<ThreadPart>((context, t) => {
                SetModelProperties(context, t);
                UpdateViewCount(context, t);
                                          });

            OnGetEditorShape<ThreadPart>(SetModelProperties);
            OnUpdateEditorShape<ThreadPart>(SetModelProperties);

            OnCreated<ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnPublished<ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnUnpublished<ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnVersioned<ThreadPart>((context, part, newVersionPart) => UpdateForumPartCounters(newVersionPart));
            OnRemoved<ThreadPart>((context, part) => UpdateForumPartCounters(part));

            OnRemoved<ForumPart>((context, b) => 
                _threadService
                    .Get(context.ContentItem.As<ForumPart>())
                    .ToList()
                    .ForEach(thread => context.ContentManager.Remove(thread.ContentItem)));
        }
    
        private static void UpdateViewCount(BuildDisplayContext context, ThreadPart threadPart) {
            if (context.DisplayType == "Detail")
                threadPart.NumberOfViews++;<commit_msg>commented out view count until popularity algoritum works.<commit_after>using System;
using System.Linq;
using System.Web.Routing;
using JetBrains.Annotations;
using NGM.Forum.Extensions;
using NGM.Forum.Models;
using NGM.Forum.Services;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Models;
using Orchard.Data;

namespace NGM.Forum.Handlers {
    [UsedImplicitly]
    public class ThreadPartHandler : ContentHandler {
        private readonly IPostService _postService;
        private readonly IThreadService _threadService;
        private readonly IForumService _forumService;

        public ThreadPartHandler(IRepository<ThreadPartRecord> repository, IPostService postService, IThreadService threadService, IForumService forumService, RequestContext requestContext) {
            _postService = postService;
            _threadService = threadService;
            _forumService = forumService;

            Filters.Add(StorageFilter.For(repository));

            OnGetDisplayShape<ThreadPart>((context, t) => {
                SetModelProperties(context, t);
                //UpdateViewCount(context, t);
                                          });

            OnGetEditorShape<ThreadPart>(SetModelProperties);
            OnUpdateEditorShape<ThreadPart>(SetModelProperties);

            OnCreated<ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnPublished<ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnUnpublished<ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnVersioned<ThreadPart>((context, part, newVersionPart) => UpdateForumPartCounters(newVersionPart));
            OnRemoved<ThreadPart>((context, part) => UpdateForumPartCounters(part));

            OnRemoved<ForumPart>((context, b) => 
                _threadService
                    .Get(context.ContentItem.As<ForumPart>())
                    .ToList()
                    .ForEach(thread => context.ContentManager.Remove(thread.ContentItem)));
        }
    
        private static void UpdateViewCount(BuildDisplayContext context, ThreadPart threadPart) {
            if (context.DisplayType == "Detail")
                threadPart.NumberOfViews++;
{'fraction_non_alphanumeric': 0.09046454767726161, 'fraction_numerical': 0.0, 'mean_word_length': 3.0214477211796247, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4250008', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1115, 'n_words': 208}