<commit_before>﻿using System;
using System.Linq;

using Aggregator.Core;
using Aggregator.Core.Facade;
using Aggregator.Core.Interfaces;

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.Framework.Server;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.Server.Core;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace Aggregator.ConsoleApp
{
    public class RequestContext : IRequestContext
    {
        private readonly string teamProjectCollectionUrl;

        private readonly string teamProjectName;

        public RequestContext(string teamProjectCollectionUrl, string teamProjectName)
        {
            this.teamProjectCollectionUrl = teamProjectCollectionUrl;
            this.teamProjectName = teamProjectName;
        }

        public string CollectionName
        {
            get
            {
                var url = new Uri(this.teamProjectCollectionUrl);

                // HACK need the Collection **name** not the Url
                var name = url.LocalPath.Replace("/tfs/", string.Empty);
                return name;
            }
        }

        public string GetProjectName(Uri projectUri)
        {
            return this.teamProjectName;
        }

        public IProjectPropertyWrapper[] GetProjectProperties(Uri projectUri)
        {
            var context = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(this.teamProjectCollectionUrl));
            var ics = context.GetService<ICommonStructureService4>();

            string projectName;
            string projectState;
            int templateId = 0;
            ProjectProperty[] projectProperties = null;
<commit_msg>FIX collection name properly computed<commit_after>﻿using System;
using System.Linq;

using Aggregator.Core;
using Aggregator.Core.Facade;
using Aggregator.Core.Interfaces;

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.Framework.Server;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.Server.Core;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace Aggregator.ConsoleApp
{
    public class RequestContext : IRequestContext
    {
        private readonly string teamProjectCollectionUrl;

        private readonly string teamProjectName;

        public RequestContext(string teamProjectCollectionUrl, string teamProjectName)
        {
            this.teamProjectCollectionUrl = teamProjectCollectionUrl;
            this.teamProjectName = teamProjectName;
        }

        public string CollectionName
        {
            get
            {
                var url = new Uri(this.teamProjectCollectionUrl);
                var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(url);
                var name = collection.CatalogNode.Resource.DisplayName;
                return name;
            }
        }

        public string GetProjectName(Uri projectUri)
        {
            return this.teamProjectName;
        }

        public IProjectPropertyWrapper[] GetProjectProperties(Uri projectUri)
        {
            var context = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(this.teamProjectCollectionUrl));
            var ics = context.GetService<ICommonStructureService4>();

            string projectName;
            string projectState;
            int templateId = 0;
            ProjectProperty[] projectProperties = null;

{'fraction_non_alphanumeric': 0.06329471602147499, 'fraction_numerical': 0.0011302627860977678, 'mean_word_length': 2.6913451511991657, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7574674', 'n_tokens_mistral': 839, 'n_tokens_neox': 816, 'n_words': 186}