<commit_before>﻿using System;
using System.Reflection;
using System.Security.Claims;
using Amazon;
using BioEngine.Core.Data;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
using Sitko.Backup;
using Sitko.Core.App.Logging;
using Sitko.Core.App.Web;
using Sitko.Core.Db.Postgres;
using Sitko.Core.Repository.EntityFrameworkCore;
using Sitko.Core.Storage;
using Sitko.Core.Storage.ImgProxy;
using Sitko.Core.Storage.Metadata.Postgres;
using Sitko.Core.Storage.S3;

namespace BioEngine.Core
{
    public abstract class BioEngineApp : WebApplication<BioEngineApp>
    {
        public static readonly string AdminRoleName = "admin";

        public static readonly AuthorizationPolicy AdminPolicy = new AuthorizationPolicyBuilder()
            .RequireClaim(ClaimTypes.Role, AdminRoleName)
            .Build();

        public static readonly string SiteTeamRoleName = "siteTeam";

        public static readonly AuthorizationPolicy SiteTeamPolicy = new AuthorizationPolicyBuilder()
            .RequireClaim(ClaimTypes.Role, SiteTeamRoleName)
            .Build();

        protected BioEngineApp(string[] args) : base(args)
        {
        }

        protected override void ConfigureLogging(LoggerConfiguration loggerConfiguration,
            LogLevelSwitcher logLevelSwitcher)
        {
            base.ConfigureLogging(loggerConfiguration, logLevelSwitcher);
            ConfigureLogLevel("Microsoft.AspNetCore", LogEventLevel.Warning);
            ConfigureLogLevel("Sitko.Core.Search.ElasticSearch.ElasticSearcher", LogEventLevel.Warning);
        }

        public BioEngineApp AddPostgresDb(bool enablePooling = true, Assembly? migrationsAssembly = null)
        {
            return AddModule<PostgresModule<BioDbContext>, PostgresDatabaseModuleConfig<BioDbContext>>(
                    (configuration, env, moduleConfig) =>
                    {<commit_msg>reduce logs<commit_after>﻿using System;
using System.Reflection;
using System.Security.Claims;
using Amazon;
using BioEngine.Core.Data;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
using Sitko.Backup;
using Sitko.Core.App.Logging;
using Sitko.Core.App.Web;
using Sitko.Core.Db.Postgres;
using Sitko.Core.Repository.EntityFrameworkCore;
using Sitko.Core.Storage;
using Sitko.Core.Storage.ImgProxy;
using Sitko.Core.Storage.Metadata.Postgres;
using Sitko.Core.Storage.S3;

namespace BioEngine.Core
{
    public abstract class BioEngineApp : WebApplication<BioEngineApp>
    {
        public static readonly string AdminRoleName = "admin";

        public static readonly AuthorizationPolicy AdminPolicy = new AuthorizationPolicyBuilder()
            .RequireClaim(ClaimTypes.Role, AdminRoleName)
            .Build();

        public static readonly string SiteTeamRoleName = "siteTeam";

        public static readonly AuthorizationPolicy SiteTeamPolicy = new AuthorizationPolicyBuilder()
            .RequireClaim(ClaimTypes.Role, SiteTeamRoleName)
            .Build();

        protected BioEngineApp(string[] args) : base(args)
        {
        }

        protected override void ConfigureLogging(LoggerConfiguration loggerConfiguration,
            LogLevelSwitcher logLevelSwitcher)
        {
            base.ConfigureLogging(loggerConfiguration, logLevelSwitcher);
            ConfigureLogLevel("Microsoft.AspNetCore", LogEventLevel.Warning);
            ConfigureLogLevel("Sitko.Core.Search.ElasticSearch.ElasticSearcher", LogEventLevel.Warning);
            ConfigureLogLevel("Microsoft.EntityFrameworkCore", LogEventLevel.Warning);
        }

        public BioEngineApp AddPostgresDb(bool enablePooling = true, Assembly? migrationsAssembly = null)
        {
            return AddModule<PostgresModule<BioDbContext>, PostgresDatabaseModuleConfig<BioDbContext>>(
                    (configuration, env, moduleConfig) =>
                    {
{'fraction_non_alphanumeric': 0.08011943269470018, 'fraction_numerical': 0.0004976362279173924, 'mean_word_length': 3.5372460496613995, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7130774', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1038, 'n_words': 219}