Skip to content
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

Merged
merged 7 commits into from
Oct 27, 2024

Conversation

tom-anders
Copy link
Collaborator

No description provided.

@tom-anders
Copy link
Collaborator Author

Not sure what's up with the unrelated test failing. It does not fail when I run it on my machine

}

@Freezed(fromJson: true)
class StudyChapterFeatures with _$StudyChapterFeatures {
Copy link
Contributor

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).

Copy link
Collaborator Author

@tom-anders tom-anders Oct 18, 2024

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)

Copy link
Collaborator Author

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: ...)

}

@Freezed(fromJson: true)
class StudyFeatures with _$StudyFeatures {
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

@veloce veloce left a 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.

@tom-anders
Copy link
Collaborator Author

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 treeParts for them)

required IList<String> topics,
required IList<StudyChapterMeta> chapters,
required StudyChapter chapter,
// Hints to display in "gamebook"/"interactive" mode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

triple slash :)

Copy link
Collaborator Author

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

@tom-anders
Copy link
Collaborator Author

(rebased against main)

@veloce veloce merged commit 19b963a into lichess-org:main Oct 27, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants