-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Study] add models to get study (chapter) as JSON and PGN #1077
Conversation
e549d06
to
11eca57
Compare
Not sure what's up with the unrelated test failing. It does not fail when I run it on my machine |
lib/src/model/study/study.dart
Outdated
} | ||
|
||
@Freezed(fromJson: true) | ||
class StudyChapterFeatures with _$StudyChapterFeatures { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For such simple models which are part of another one, I feel it is better to use a record (with a typedef if needed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I had to use bool?
instead of bool
then though, since the JSON response seems to not always actually contain these fields (and with a simple record we can't use @Default
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, solved this via @JsonKey(fromJson: ...)
lib/src/model/study/study.dart
Outdated
} | ||
|
||
@Freezed(fromJson: true) | ||
class StudyFeatures with _$StudyFeatures { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see it used in the Study
class? is it on purpose or is it an oversight? (also same remark as for StudyChapterFeatures
, a record would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah that was an oversight, it's part of Study
now
11eca57
to
8681675
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes!
I think now it would be nice to add repository tests, as we have in other repositories. I know it is usually tested end-to-end in a screen test, but here we don't have the screen yet, and I find it interesting to see some examples of the server responses in the tests.
Ok, added tests with a real world study (https://lichess.org/study/JbWtuaeK/7OJXp679) Also added support for hints and deviation comments (these are not part of the PGN, so we have to parse a subset of |
lib/src/model/study/study.dart
Outdated
required IList<String> topics, | ||
required IList<StudyChapterMeta> chapters, | ||
required StudyChapter chapter, | ||
// Hints to display in "gamebook"/"interactive" mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
triple slash :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, hope I will stop forgetting this at some point :D
07ff467
to
a01ed8a
Compare
(rebased against main) |
No description provided.