如何做企业网站推广,网络推广策划方案怎么写,网站建设公司工作室,网页设计 网站统计一下 2021 贡献过的开源项目Intro新的一年的开始了#xff0c;有很多总结和回顾还没有做#xff0c;今天就盘点一下贡献过的开源项目吧~起初想着手动地通过 Github Dashboard 来统计但是感觉有些麻烦#xff0c;还得一个个地复制标题链接等#xff0c;好麻烦#xff0… 统计一下 2021 贡献过的开源项目Intro新的一年的开始了有很多总结和回顾还没有做今天就盘点一下贡献过的开源项目吧~起初想着手动地通过 Github Dashboard 来统计但是感觉有些麻烦还得一个个地复制标题链接等好麻烦于是就想是不是可以写一个简单的小程序通过 Github 的 API 来统计呢答案是肯定的可以参考后面的示例代码Contributions过去一年的贡献如下一共提了 81 个 PR 其中有 43 个是自己维护的开源项目的 PR已从下面的 PR 中移除统计结果来自 Github 的 APIhttps://api.github.com/search/issues?page1qauthor%3Aweihanlitype%3Apris:mergedmerged:%3E2021-01-01davidfowl/DotNetCodingPatternsenhancement on Caching singletons sample code https://github.com/davidfowl/DotNetCodingPatterns/pull/11domaindrivendev/Swashbuckle.AspNetCoreEnhancement for SwaggerUIMiddleware https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/2214dotnet/aspnetcoreFix http logging log typo https://github.com/dotnet/aspnetcore/pull/36871Update 10_bug_report.md https://github.com/dotnet/aspnetcore/pull/36922dotnet/coreUpdate for .NET 6 release https://github.com/dotnet/core/pull/6892dotnet/dotnet-monitorupdate windows build script https://github.com/dotnet/dotnet-monitor/pull/40dotnet/formatRemove unnecessary config https://github.com/dotnet/format/pull/1486dotnet/issue-labeleruse generic host https://github.com/dotnet/issue-labeler/pull/15dotnet/mauiUpdate MauiAppBuilder.cs https://github.com/dotnet/maui/pull/3445dotnet/runtimeUpdate ConfigurationManager https://github.com/dotnet/runtime/pull/59600dotnet/sdkAdd self contained short flag https://github.com/dotnet/sdk/pull/19681Use null-coalescing assignment operator https://github.com/dotnet/sdk/pull/20678dotnetcore/CAPmake OperateResult._errors readonly https://github.com/dotnetcore/CAP/pull/869fix typo in comment https://github.com/dotnetcore/CAP/pull/870Use KeyExistsAsync for exists check https://github.com/dotnetcore/CAP/pull/1004dotnetcore/FastGithubFix build for .NET 6 with the latest SDK and some warning and typo https://github.com/dotnetcore/FastGithub/pull/26Remove unnecessary config https://github.com/dotnetcore/FastGithub/pull/84EdiWang/MoongladeCommon.props enhancement https://github.com/EdiWang/Moonglade/pull/566IEvangelist/blazoratorsGithub CodeSpaces support https://github.com/IEvangelist/blazorators/pull/3Refine the generator https://github.com/IEvangelist/blazorators/pull/6Apply file-scoped namespace style and skip none partial classes https://github.com/IEvangelist/blazorators/pull/7IEvangelist/pwned-clientRemove IsExternalInit https://github.com/IEvangelist/pwned-client/pull/6kubernetes-client/csharpUpdate TokenFileAuth https://github.com/kubernetes-client/csharp/pull/631Expose kube config default location https://github.com/kubernetes-client/csharp/pull/635Makes realFileSystem readonly https://github.com/kubernetes-client/csharp/pull/655AddRange extension enhancement https://github.com/kubernetes-client/csharp/pull/771LemonSharp/Admin.FrontEndAdd Github CI support https://github.com/LemonSharp/Admin.FrontEnd/pull/2Add dotnet-monitor https://github.com/LemonSharp/Admin.FrontEnd/pull/4LemonSharp/UserPublish event when user register success https://github.com/LemonSharp/User/pull/1LemonSharp/VaccinationCoreImplement AppointmentQueries/VaccinationQueries https://github.com/LemonSharp/VaccinationCore/pull/1LemonSharp/VaccinationSiteFeat/add appointment api https://github.com/LemonSharp/VaccinationSite/pull/1Add GetSiteInfoById API https://github.com/LemonSharp/VaccinationSite/pull/2Add dotnet-monitor sidecar https://github.com/LemonSharp/VaccinationSite/pull/3Enable swagger on production https://github.com/LemonSharp/VaccinationSite/pull/4microsoft/reverse-proxyFix typo https://github.com/microsoft/reverse-proxy/pull/1245Use WaitAsync https://github.com/microsoft/reverse-proxy/pull/1306night-moon-studio/NatashaPadUpdate to .NET 6 https://github.com/night-moon-studio/NatashaPad/pull/10pengweiqhca/Xunit.DependencyInjectionAdd Github Actions CI https://github.com/pengweiqhca/Xunit.DependencyInjection/pull/55Update template https://github.com/pengweiqhca/Xunit.DependencyInjection/pull/59StackExchange/StackExchange.RedisAdd support for GETDEL command https://github.com/StackExchange/StackExchange.Redis/pull/1840Makes StreamEntry constructor public https://github.com/StackExchange/StackExchange.Redis/pull/1923Tyrrrz/CliWrapRemove unused dependencies https://github.com/Tyrrrz/CliWrap/pull/132ua-parser/uap-csharpUpdate target framework for netstandard2.0 https://github.com/ua-parser/uap-csharp/pull/65希望接下来的一年能够有更多更高质量的开源贡献~很多开源项目的贡献很简单并不会很复杂大家也可以尽可能的贡献一些自己的力量来让 .NET 社区的开源项目越来越好~Sample上面的统计结果来自上面提到的 API- author 用户名
- typepr 返回 PR
- is:merged 过滤合并的 PR
- merged: 根据 PR 合并时间过滤
- page: 当前页码默认是 1, 用来分页Github API result上面的返回结果中的 html_url 对应的就是对应 PR 的 HTML 页面地址, title/body 对应 PR 的标题和描述信息created_at 和 closed_at 分别对应 PR 的创建和合并时间写了一个简单的小程序来统计结果示例代码如下using System.Net.Http.Json;
using System.Text.Json.Nodes;
using WeihanLi.Extensions;const int pageCount 30;
const string userName weihanli;
const string urlFormat $search/issues?page{{0}}qauthor%3A{userName}type%3Apris:mergedmerged:%3E2021-01-01;var prList new ListGithubPRModel();
var itemsCount 0;
var pageNum 1;using var httpClient new HttpClient()
{BaseAddress new Uri(https://api.github.com/)
};
// https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required
httpClient.DefaultRequestHeaders.TryAddWithoutValidation(User-Agent, Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36);do
{var url urlFormat.FormatWith(pageNum.ToString());using var response await httpClient.GetAsync(url);var responseText await response.Content.ReadAsStringAsync();var responseObj JsonNode.Parse(responseText);ArgumentNullException.ThrowIfNull(responseObj);var items responseObj[items]?.AsArray();ArgumentNullException.ThrowIfNull(items);itemsCount items.Count;foreach (var item in items){prList.Add(new GithubPRModel(){Title item[title]?.GetValuestring(),Body item[body]?.GetValuestring(),Url item[html_url]?.GetValuestring(),CreatedAt item[created_at]?.GetValueDateTimeOffset(),ClosedAt item[closed_at]?.GetValueDateTimeOffset()});}pageNum;
} while (itemsCount pageCount);var totalCount prList.Count;
prList.RemoveAll(x userName.Equals(x.UserName, StringComparison.OrdinalIgnoreCase));
var excludedCount prList.Count;
Console.WriteLine($Total:{totalCount}, excludedCount: {excludedCount});Console.WriteLine(Completed);
Console.ReadLine();internal class GithubPRModel
{private string _url;public string Title { get; set; }public string Body { get; set; }public DateTimeOffset? CreatedAt { get; set; }public DateTimeOffset? ClosedAt { get; set; }public string Url{get _url;set{_url value;if (!string.IsNullOrEmpty(_url)){var index _url.IndexOf(/pull/, StringComparison.OrdinalIgnoreCase);RepoUrl _url[..index];RepoName RepoUrl.Replace(https://github.com/, );UserName RepoName[..RepoName.IndexOf(/)];}}}public string UserName { get; private set; }public string RepoName { get; private set; }public string RepoUrl { get; private set; }
}上面的结果就是用这个示例中的代码生成的为了方便也可以改造一下上面的代码直接生成 Markdown 内容上面的贡献内容就是下面这段生成 markdown 的代码生成出来的你也可以根据自己需要进行一些定制var mdContent prList.GroupBy(g new
{g.RepoName,g.RepoUrl
})
.OrderBy(g g.Key.RepoName)
.Select(g $- [{g.Key.RepoName}]({g.Key.RepoUrl})
{g.OrderBy(x x.CreatedAt).Select(x $ - {x.Title} {x.Url}).StringJoin(Environment.NewLine)}
)
.StringJoin(Environment.NewLine);await File.WriteAllTextAsync(result.md, mdContent);StringJoin 是一个基于 string.Join 的扩展方法More上面的示例中有一个需要注意的地方就是 UserAgent 请求头的配置如果不配置Github 就会返回一个 403 可以参考 Github 文档 https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required另外还有一些可以优化的地方比如说可以使用 System.Text.Json 的 GetFromJsonAsync 方法来简化 http response JSON 反序列化另外可以考虑使用 Github 提供的客户端因为我的需求比较简单所以直接调了这个 API也可以考虑使用 Github 客户端 octokitReferenceshttps://api.github.com/search/issues?page1qstate%3Aclosedauthor%3Aweihanlitype%3Apris:mergedmerged:%3E2021-01-01https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-requiredhttps://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests#search-based-on-the-state-of-an-issue-or-pull-requesthttps://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests#search-by-authorhttps://stackoverflow.com/questions/17412809/how-to-get-my-pull-requests-from-github-apihttps://github.com/WeihanLi/SamplesInPractice/blob/master/GithubAPISample/Program.cshttps://github.com/octokit/octokit.net