<commit_before>﻿// ==========================================================================
//  Squidex Headless CMS
// ==========================================================================
//  Copyright (c) Squidex UG (haftungsbeschraenkt)
//  All rights reserved. Licensed under the MIT license.
// ==========================================================================

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Squidex.Areas.Api.Controllers.News.Models;
using Squidex.ClientLibrary;

namespace Squidex.Areas.Api.Controllers.News.Service
{
    public sealed class FeaturesService
    {
        private const int FeatureVersion = 11;
        private readonly QueryContext flatten = QueryContext.Default.Flatten();
        private readonly IContentsClient<NewsEntity, FeatureDto> client;

        public sealed class NewsEntity : Content<FeatureDto>
        {
        }

        public FeaturesService(IOptions<MyNewsOptions> options)
        {
            if (options.Value.IsConfigured())
            {
                var squidexOptions = new SquidexOptions
                {
                    AppName = options.Value.AppName,
                    ClientId = options.Value.ClientId,
                    ClientSecret = options.Value.ClientSecret,
                    Url = "https://cloud.squidex.io"
                };

                var clientManager = new SquidexClientManager(squidexOptions);

                client = clientManager.CreateContentsClient<NewsEntity, FeatureDto>("feature-news");
            }
        }

        public async Task<FeaturesDto> GetFeaturesAsync(int version = 0)
        {
            var result = new FeaturesDto { Features = new List<FeatureDto>(), Version = FeatureVersion };

            if (client != null && version < FeatureVersion)
            {<commit_msg>Update version.<commit_after>﻿// ==========================================================================
//  Squidex Headless CMS
// ==========================================================================
//  Copyright (c) Squidex UG (haftungsbeschraenkt)
//  All rights reserved. Licensed under the MIT license.
// ==========================================================================

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Squidex.Areas.Api.Controllers.News.Models;
using Squidex.ClientLibrary;

namespace Squidex.Areas.Api.Controllers.News.Service
{
    public sealed class FeaturesService
    {
        private const int FeatureVersion = 13;
        private readonly QueryContext flatten = QueryContext.Default.Flatten();
        private readonly IContentsClient<NewsEntity, FeatureDto> client;

        public sealed class NewsEntity : Content<FeatureDto>
        {
        }

        public FeaturesService(IOptions<MyNewsOptions> options)
        {
            if (options.Value.IsConfigured())
            {
                var squidexOptions = new SquidexOptions
                {
                    AppName = options.Value.AppName,
                    ClientId = options.Value.ClientId,
                    ClientSecret = options.Value.ClientSecret,
                    Url = "https://cloud.squidex.io"
                };

                var clientManager = new SquidexClientManager(squidexOptions);

                client = clientManager.CreateContentsClient<NewsEntity, FeatureDto>("feature-news");
            }
        }

        public async Task<FeaturesDto> GetFeaturesAsync(int version = 0)
        {
            var result = new FeaturesDto { Features = new List<FeatureDto>(), Version = FeatureVersion };

            if (client != null && version < FeatureVersion)
            {
{'fraction_non_alphanumeric': 0.19246972090573986, 'fraction_numerical': 0.001579778830963665, 'mean_word_length': 2.61465271170314, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '2406513', 'n_tokens_mistral': 934, 'n_tokens_neox': 867, 'n_words': 199}