<commit_before>﻿using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using MiniMVC;
using QuartzNetWebConsole.Models;

namespace QuartzNetWebConsole.Controllers {
    public class LogController : Controller {
        private readonly IQueryable<LogEntry> logsQ = Setup.Logger ?? Enumerable.Empty<LogEntry>().AsQueryable();

        public int DefaultPageSize { get; set; }

        public LogController() {
            DefaultPageSize = 25;
        }

        public override IResult Execute(HttpContextBase context) {
            string contentType = null;
            var qs = context.Request.QueryString;
            if (qs.AllKeys.Contains("rss")) {
                ViewName = "QuartzNetWebConsole.Resources.Rss.html";
                contentType = "application/rss+xml";
            }
            var thisUrl = context.Request.Url.ToString().Split('?')[0];
            var pageSize = GetPageSize(qs);
            var pagination = new PaginationInfo {
                FirstItemIndex = GetStartIndex(qs),
                PageSize = pageSize,
                TotalItemCount = logsQ.Count(),
                PageUrl = "log.ashx?start=!0&max=" + pageSize,
            };
            var logs = logsQ.Skip(pagination.FirstItemIndex).Take(pagination.PageSize);
            return new ViewResult(new {logs, pagination, thisUrl}, ViewName) {
                ContentType = contentType,
            };
        }

        public int GetPageSize(NameValueCollection nv) {
            try {
                return int.Parse(nv["max"]);
            } catch {<commit_msg>run query in controller<commit_after>﻿using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using MiniMVC;
using QuartzNetWebConsole.Models;

namespace QuartzNetWebConsole.Controllers {
    public class LogController : Controller {
        private readonly IQueryable<LogEntry> logsQ = Setup.Logger ?? Enumerable.Empty<LogEntry>().AsQueryable();

        public int DefaultPageSize { get; set; }

        public LogController() {
            DefaultPageSize = 25;
        }

        public override IResult Execute(HttpContextBase context) {
            string contentType = null;
            var qs = context.Request.QueryString;
            if (qs.AllKeys.Contains("rss")) {
                ViewName = "QuartzNetWebConsole.Resources.Rss.html";
                contentType = "application/rss+xml";
            }
            var thisUrl = context.Request.Url.ToString().Split('?')[0];
            var pageSize = GetPageSize(qs);
            var pagination = new PaginationInfo {
                FirstItemIndex = GetStartIndex(qs),
                PageSize = pageSize,
                TotalItemCount = logsQ.Count(),
                PageUrl = "log.ashx?start=!0&max=" + pageSize,
            };
            var logs = logsQ.Skip(pagination.FirstItemIndex).Take(pagination.PageSize).ToList();
            return new ViewResult(new {logs, pagination, thisUrl}, ViewName) {
                ContentType = contentType,
            };
        }

        public int GetPageSize(NameValueCollection nv) {
            try {
                return int.Parse(nv["max"]);
            } catch {
{'fraction_non_alphanumeric': 0.09935404490925868, 'fraction_numerical': 0.002460781298062135, 'mean_word_length': 2.1420289855072463, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5893074', 'n_tokens_mistral': 875, 'n_tokens_neox': 842, 'n_words': 181}