Fixing bug unable to select level

This commit is contained in:
Sergiotarxz 2024-12-02 13:16:29 +01:00
parent cc7383a402
commit dbc8259920
2 changed files with 22 additions and 5 deletions

View File

@ -221,10 +221,14 @@ sub next_char( $self, $accesibility, $type = undef ) {
sub _next_review_char( $self, $type = undef ) {
my $kanji_resultset = JapaChar::Schema->Schema->resultset('Kanji');
my $grade = $type;
if (!defined $type) {
$grade = { is => undef };
}
my @chars = $kanji_resultset->search(
{
score => { '>=' => 300 },
( ( $type ne 'all' ) ? ( grade => { is => $type } ) : () )
( ( $type ne 'all' ) ? ( grade => $grade ) : () )
},
{
order_by => { -asc => \'RANDOM()' },
@ -240,15 +244,19 @@ sub _next_review_char( $self, $type = undef ) {
sub _next_learning_char( $self, $type = undef ) {
my $kanji_resultset = JapaChar::Schema->Schema->resultset('Kanji');
my @candidate_chars = $self->_retrieve_started_chars_not_finished($type);
if ( @candidate_chars < 5 ) {
my $grade = $type;
if (!defined $type) {
$grade = { is => undef };
}
if ( @candidate_chars < 3 ) {
my @new_chars = $kanji_resultset->search(
{
-not_bool => 'started',
( ( $type ne 'all' ) ? ( grade => { is => $type } ) : () )
( ( $type ne 'all' ) ? ( grade => $grade ) : () )
},
{
order_by => { -asc => [ \'grade IS NULL', 'grade', 'id' ] },
rows => 5 - scalar @candidate_chars,
rows => 3 - scalar @candidate_chars,
}
);
for my $char (@new_chars) {
@ -262,9 +270,13 @@ sub _next_learning_char( $self, $type = undef ) {
sub _retrieve_started_chars_not_finished( $self, $type ) {
my $kanji_resultset = JapaChar::Schema->Schema->resultset('Kanji');
my $grade = $type;
if (!defined $type) {
$grade = { is => undef };
}
return $kanji_resultset->search(
{
( ( $type ne 'all' ) ? ( grade => { is => $type } ) : () ),
( ( $type ne 'all' ) ? ( grade => $grade ) : () ),
score => { '<' => 100 },
-bool => 'started',
}

View File

@ -32,6 +32,11 @@
<developer_name>sergiotarxz</developer_name>
<releases>
<release version="v1.04" date="2024-12-02">
<description>
<p>Fixing bug unable to select specific level and decreasing number of simultaneus kanji to learn.</p>
</description>
</release>
<release version="v1.03" date="2024-12-02">
<description>
<p>Improving further the description to make know users about they are supposed to fail when they are starting because I got a bad review complaining about that.</p>