[replacement with sqlx] LanguageCountClient #770
Merged
kenkoooo merged 6 commits intokenkoooo:masterfrom Aug 22, 2020
Merged
Conversation
kenkoooo
reviewed
Aug 17, 2020
atcoder-problems-backend/sql-client/src/internal/virtual_contest_manager.rs
Outdated
Show resolved
Hide resolved
kenkoooo
reviewed
Aug 17, 2020
| #[async_trait] | ||
| impl LanguageCountClient for PgPool { | ||
| async fn update_language_count(&self, submissions: &[Submission]) -> Result<()> { | ||
| let re = Regex::new(r"\d* \(.*\)").unwrap(); |
Owner
There was a problem hiding this comment.
これは古いやつから残っているのですが、AtCoder 側の入力ミス?で Fortran(GNU Fortran 9.2.1) という書式のものが登場して、これをパースできないので、カッコの前のスペースを消して \d*\(.*\) にしてもらっても良いですか?
Contributor
Author
There was a problem hiding this comment.
PyPy2 (7.3.0) を従来どおり PyPy へと変換させることなどを考えると正規表現のほうはそのまま保っておくべきと考えました。
Fortran(GNU Fortran 9.2.1) に関してはイレギュラー扱いということで starts_with を使って判定するようにしてみました。
また、言語をsimplifyする部分のロジックを関数に切り出して単体テストを行うようにしました。
いくつかテストケースを書いていますが、過不足があったら教えていただけると助かります。
Owner
There was a problem hiding this comment.
すみません、たぶん寝ながら正規表現書いてました… \d*\s*\(.*\) でどうでしょう?
関数に切り出すのはめっちゃ良いと思います!ありがとうございます…!
Contributor
Author
There was a problem hiding this comment.
その正規表現で良さそうですね!修正しました。
kenkoooo
approved these changes
Aug 22, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue: #701
LanguageCountClientの sqlx 版です。やったこと
LanguageCountClientを作って、それをsqlx::postgres::PgPoolに対して実装LanguageCountClientのテストを作成(もとのテストを移植)