public async Task <Models.User> Get(string login)
        {
            GitHubClient github = GitHubHelper.GetClient();

            Octokit.User userBase = await github.User.Get(login);

            Models.User user = new Models.User(userBase);
            return(user);
        }
Beispiel #2
0
        // GET: Language badge
        public async Task <ActionResult> GetLanguageBadge()
        {
            Response.ContentType = "image/svg+xml";

            var req = System.Web.HttpContext.Current.Request;
            var bqd = new BadgeQueryData(req);
            var c   = await GitHubHelper.GetClient();

            var rData = await c.GetRepoData(bqd);

            var badge     = new LanguageBadge(bqd, rData.Lang);
            var viewModel = new LanguageBadgeViewModel(badge);

            return(View("LanguageBadge", viewModel));
        }
Beispiel #3
0
        // GET: Top rated badge
        public async Task <ActionResult> GetTopRatedBadge()
        {
            Response.ContentType = "image/svg+xml";

            var req = System.Web.HttpContext.Current.Request;
            var bqd = new BadgeQueryData(req);
            var c   = await GitHubHelper.GetClient();

            var repoData = await c.GetRepoData(bqd);

            var langTopRatedData = await GitHubHelper.GetTopCategories(repoData.Lang);

            foreach (var cat in langTopRatedData.Categories)
            {
                Debug.WriteLine($"cp: {cat.PercentageString}, f: {cat.From}, t: {cat.To}");
            }

            var badge     = new TopRatedBadge(bqd, "0.05%", repoData.Lang);
            var viewModel = new TopRatedBadgeViewModel(badge);

            return(View("TopRatedBadge", viewModel));
        }
Beispiel #4
0
        // GET: Top 1000 badge
        public async Task <ActionResult> GetTop1000Badge()
        {
            Response.ContentType = "image/svg+xml";

            var req = System.Web.HttpContext.Current.Request;
            var bqd = new BadgeQueryData(req);
            var c   = await GitHubHelper.GetClient();

            //var repoData = await GitHubHelper.GetRepoData(bqd.User, bqd.Repo);
            var repoData = await c.GetRepoData(bqd);

            Debug.Write("GOOOOO!!!!!!!!!!");
            foreach (var l in Languages.All)
            {
                Debug.WriteLine("l: " + l.Name);
                var repos = c.Search.SearchRepo(new SearchRepositoriesRequest
                {
                    Language  = l.OctokitLanguage,
                    Order     = SortDirection.Descending,
                    SortField = RepoSearchSort.Stars,
                    PerPage   = 100,
                    Page      = 1
                }).Result.Items;
                Debug.WriteLine("repo: " + repos.FirstOrDefault()?.FullName);
            }
            var top1000 = await DataGetter.GetTop1000(repoData.Lang.ApiName);

            var place = top1000?.Repos?.FirstOrDefault(r => r.UserName.Equals(repoData.UserName) &&
                                                       r.RepoName.Equals(repoData.RepoName))?.Place
                        ?? 0;

            var badge     = new Top1000Badge(bqd, place.ToString(), repoData.Lang);
            var viewModel = new Top1000BadgeViewModel(badge);

            return(View("Top1000Badge", viewModel));
        }