<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Knapcode.NuGetTools.Logic;
using Knapcode.NuGetTools.Logic.Models.Framework;
using Knapcode.NuGetTools.Logic.Models.Version;
using Knapcode.NuGetTools.Logic.Models.VersionRange;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;

namespace Knapcode.NuGetTools.Website
{
    public class HomeController : Controller
    {
        private static readonly Dictionary<string, string> _versionRedirects = new Dictionary<string, string>
        {
            { "3.5.0-beta2", "3.5.0-beta2-1484" }
        };
        
        static HomeController()
        {
            var typeName = typeof(HomeController).Name;
            ControllerName = typeName.Substring(0, typeName.Length - "Controller".Length);
        }

        private readonly IToolsFactory _toolsFactory;
        private readonly IUrlHelperFactory _urlHelperFactory;

        public HomeController(IToolsFactory toolsFactory, IUrlHelperFactory urlHelperFactory)
        {
            _toolsFactory = toolsFactory;
            _urlHelperFactory = urlHelperFactory;
        }

        public static string ControllerName { get; }

        [HttpGet("/")]
        public async Task<IActionResult> Index(CancellationToken token)
        {
            var versions = await _toolsFactory.GetAvailableVersionsAsync(token);

            var nuGetVersion = versions.First();

            return new RedirectToActionResult(
                nameof(SelectedVersionIndex),
                ControllerContext.ActionDescriptor.ControllerName,
                new { nuGetVersion },<commit_msg>Add redirects for previous *-* versions<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Knapcode.NuGetTools.Logic;
using Knapcode.NuGetTools.Logic.Models.Framework;
using Knapcode.NuGetTools.Logic.Models.Version;
using Knapcode.NuGetTools.Logic.Models.VersionRange;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;

namespace Knapcode.NuGetTools.Website
{
    public class HomeController : Controller
    {
        /// <summary>
        /// This is the canonical first version that supports "*-*" for version ranges. The specification is here:
        /// https://github.com/NuGet/Home/pull/9104
        /// </summary>
        private const string StarDashStarVersion = "5.5.0-floating.7611";

        private static readonly Dictionary<string, string> _versionRedirects = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
        {
            { "3.5.0-beta2", "3.5.0-beta2-1484" },
            { "5.5.0-floating.7018", StarDashStarVersion },
            { "5.5.0-floating.7250", StarDashStarVersion },
        };
        
        static HomeController()
        {
            var typeName = typeof(HomeController).Name;
            ControllerName = typeName.Substring(0, typeName.Length - "Controller".Length);
        }

        private readonly IToolsFactory _toolsFactory;
        private readonly IUrlHelperFactory _urlHelperFactory;

        public HomeController(IToolsFactory toolsFactory, IUrlHelperFactory urlHelperFactory)
        {
            _toolsFactory = toolsFactory;
            _urlHelperFactory = urlHelperFactory;
        }

        public static string ControllerName { get; }

        [HttpGet("/")]
        public async Task<IActionResult> Index(CancellationToken token)
        {
            var versions = await _toolsFactory.GetAvailableVersionsAsync(token);

            var nuGetVersion = versions.First();

            return new RedirectToActionResult(
                nameof(SelectedVersionIndex),
                ControllerContext.ActionDescriptor.ControllerName,
                new { nuGetVersion },
{'fraction_non_alphanumeric': 0.08717020175892395, 'fraction_numerical': 0.013191929643041904, 'mean_word_length': 2.739845261121857, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, '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': '4440063', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1017, 'n_words': 211}