예제 #1
0
        public async Task RunAsync(CommandLineOptions options)
        {
            var git   = new GitCommands(options.GetGitOptions());
            var files = await git.GetFilesAsync().ConfigureAwait(false);

            var gitFileAnalyzer = new GitFileAnalyzer(options.GetFileAnalyzerOptions(), git);

            ICollection <AuthorStatistics> authorStatistics;

            using (var progressBar = CreateProgressBar(files.Count))
            {
                // ReSharper disable once AccessToDisposedClosure => false positive
                authorStatistics = await gitFileAnalyzer.BlameFilesAsync(files, progress => AdvanceProgressBar(progressBar, progress)).ConfigureAwait(false);

                var commitStatistics = await git.ShortlogAsync().ConfigureAwait(false);

                foreach (var commitStatistic in commitStatistics)
                {
                    var authorStatistic = authorStatistics.SingleOrDefault(x => x.Author.Equals(commitStatistic.Key));
                    if (authorStatistic == null)
                    {
                        authorStatistic = new AuthorStatistics(commitStatistic.Key);
                        authorStatistics.Add(authorStatistic);
                    }

                    authorStatistic.CommitCount = commitStatistic.Value;
                }

                var merger = new AuthorsMerger(options.GetAuthorMergeOptions());
                authorStatistics = merger.Merge(authorStatistics);
            }

            WriteOutput(options, authorStatistics);
            DisplaySummary(authorStatistics);
        }
예제 #2
0
        private void LinkAuthorStatistics(BookResource resource, AuthorStatistics authorStatistics)
        {
            if (authorStatistics?.BookStatistics != null)
            {
                var dictBookStats = authorStatistics.BookStatistics.ToDictionary(v => v.BookId);

                resource.Statistics = dictBookStats.GetValueOrDefault(resource.Id).ToResource();
            }
        }
예제 #3
0
        public static AuthorStatisticsResource ToResource(this AuthorStatistics model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new AuthorStatisticsResource
            {
                BookCount = model.BookCount,
                BookFileCount = model.BookFileCount,
                SizeOnDisk = model.SizeOnDisk
            });
        }
예제 #4
0
        public override void OnDoubleClick(Mobile from)
        {
            base.OnDoubleClick(from);

            AuthorStatistics ast = ForumCore.GetAuthorStatistics(from.Serial.Value);

            if (ast.Banned)
            {
                from.SendMessage("You have been banned from this forum!");
                return;
            }

            ForumCore.Threads.Sort(new DateSort());
            from.CloseGump(typeof(ForumGump));
            from.SendGump(new ForumGump(from, 0));
        }
예제 #5
0
        public ICollection <AuthorStatistics> Merge(ICollection <AuthorStatistics> authorStatistics)
        {
            var processedAuthors = new List <string>();
            var result           = new List <AuthorStatistics>();

            foreach (var authorsToMergeEntry in _options.AuthorsToMerge)
            {
                var existingAuthorStatistics = authorStatistics.Where(x => authorsToMergeEntry.Value.Contains(x.Author)).ToList();
                var newName             = authorsToMergeEntry.Key;
                var newAuthorStatistics = AuthorStatistics.MergeFrom(newName, existingAuthorStatistics);
                result.Add(newAuthorStatistics);

                processedAuthors.AddRange(authorsToMergeEntry.Value);
            }

            var unprocessedAuthors = authorStatistics.Where(x => !processedAuthors.Contains(x.Author)).ToList();

            return(result.Concat(unprocessedAuthors).ToList());
        }
예제 #6
0
        public async Task <AuthorStatistics> GetStatistics()
        {
            await using var connection = ConfigurationExtensions.GetConnection(_configuration);
            var sql = $@"
                     SELECT    {LanguageSchema.Table}.{LanguageSchema.Columns.Code} AS code,
                               COUNT({AuthorNameSchema.Table}.{AuthorNameSchema.Columns.LanguageId}) AS count
                     FROM      {AuthorNameSchema.Table} AS {AuthorNameSchema.Table}
                     LEFT JOIN {LanguageSchema.Table} AS {LanguageSchema.Table}
                     ON        {AuthorNameSchema.Table}.{AuthorNameSchema.Columns.LanguageId} = {LanguageSchema.Table}.{LanguageSchema.Columns.Id}
                     GROUP BY  {AuthorNameSchema.Table}.{AuthorNameSchema.Columns.LanguageId}
                     ORDER BY  Count DESC";

            var statistics = (await connection.QueryAsync <(string code, int count)>(sql)).ToList();
            var result     = new AuthorStatistics
            {
                Languages = statistics.ToDictionary(x => x.code, x => x.count),
                Total     = statistics.Sum(x => x.count)
            };

            return(result);
        }
예제 #7
0
        public async Task <ICollection <AuthorStatistics> > BlameFilesAsync(ICollection <string> files, Action <Progress> progressReporter = null)
        {
            var result = new Dictionary <string, AuthorStatistics>();

            var sw = new Stopwatch();

            sw.Start();

            var fileCounter = 0;

            await files.ForEachAsync(_options.ParallelBlameProcesses, async file =>
            {
                var fileStatistics = await _git.BlameAsync(file).ConfigureAwait(false);

                lock (result)
                {
                    // process results
                    foreach (var author in fileStatistics.Authors)
                    {
                        if (!result.TryGetValue(author, out var stats))
                        {
                            stats          = new AuthorStatistics(author);
                            result[author] = stats;
                        }

                        stats.ProcessFileStats(file, fileStatistics.LinesCountByAuthor[author]);
                    }

                    if (progressReporter != null)
                    {
                        fileCounter++;
                        var progress = new Progress(fileCounter, files.Count, sw.Elapsed);
                        progressReporter(progress);
                    }
                }
            }).ConfigureAwait(false);

            sw.Stop();
            return(result.Values.ToList());
        }
예제 #8
0
 private void LinkAuthorStatistics(AuthorResource resource, AuthorStatistics authorStatistics)
 {
     resource.Statistics = authorStatistics.ToResource();
 }
예제 #9
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            switch (info.ButtonID)
            {
            case 1:                     // #1 Site's Url
            {
                from.CloseGump(typeof(WebstoneGump));
                from.SendGump(new WebstoneGump());
                from.SendSound(1224);                                 // 1224= click noise
                sender.LaunchBrowser("http://DragonKnights.homeip.net");
                break;
            }

            case 2:                     // #2 Site's url
            {
                from.CloseGump(typeof(WebstoneGump));
                from.SendGump(new WebstoneGump());
                from.SendSound(1224);                                 // 1224= click noise
                sender.LaunchBrowser("http://dragonknights.kicks-ass.net/e107_plugins/forum/forum.php");
                break;
            }

            case 3:                     // #3 Site's url
            {
                AuthorStatistics ast = ForumCore.GetAuthorStatistics(from.Serial.Value);
                if (ast.Banned)
                {
                    from.SendMessage("You have been banned from this forum!");
                    return;
                }
                ForumCore.Threads.Sort(new DateSort());
                from.CloseGump(typeof(ForumGump));
                from.SendSound(1224);                                 // 1224= click noise
                from.SendGump(new ForumGump(from, 0));
                break;
            }

            case 4:                     // #4 Site's Url
            {
                from.CloseGump(typeof(WebstoneGump));
                from.SendGump(new WebstoneGump());
                from.SendSound(1224);                                 // 1224= click noise
                sender.LaunchBrowser("http://uo.stratics.com/");
                break;
            }

            case 5:                     // #5 Site's url
            {
                from.CloseGump(typeof(WebstoneGump));
                from.SendGump(new WebstoneGump());
                from.SendSound(1224);                                 // 1224= click noise
                sender.LaunchBrowser("http://dragonknights.kicks-ass.net/download.php?view.3");
                break;
            }

            case 6:                     // #6 Site's url
            {
                from.CloseGump(typeof(WebstoneGump));
                from.SendGump(new WebstoneGump());
                from.SendSound(1224);                                 // 1224= click noise
                sender.LaunchBrowser("http://dragonknights.kicks-ass.net/download.php?view.1");
                //sender.LaunchBrowser( "http://aaaservices.homeip.net/TeamSpeak.htm" );
                break;
            }

            case 7:                     // #7 Site's url
            {
                from.CloseGump(typeof(WebstoneGump));
                from.SendGump(new WebstoneGump());
                from.SendSound(1224);                                 // 1224= click noise
                sender.LaunchBrowser("http://aaaservices.homeip.net/UO/status.html");
                break;
            }

            case 8:                     // #8 Site's url
            {
                from.CloseGump(typeof(WebstoneGump));
                from.SendGump(new WebstoneGump());
                from.SendSound(1224);                                 // 1224= click noise
                sender.LaunchBrowser("http://www.xtremetop100.com/in.php?site=1132300022");
                sender.LaunchBrowser("http://www.gamesites200.com/ultimaonline/in.php?id=1874");
                break;
            }

            case 9:                     // #9 Site's url
            {
                from.CloseGump(typeof(WebstoneGump));
                from.SendGump(new WebstoneGump());
                from.SendSound(1224);                                 // 1224= click noise
                sender.LaunchBrowser("http://aaaservices.homeip.net/index.html");
                break;
            }


            case 0:                     // Close button
            {
                from.SendSound(1224);   // 1224= click noise
                from.CloseGump(typeof(WebstoneGump));
                from.SendSound(240);
                break;
            }



//				case 10: // #10 Site's url
//					{
//						sender.LaunchBrowser( "http://www.jeff6o6-hosting.com/" );
//						break;
//					}
            }
        }