zeeguu/core/word_scheduling/arts/words_to_study.py
def bookmarks_to_study(user, desired_bookmarks_count=10):
    """

    Returns a list of bookmarks with the highest priorities
    An equal amount of bookmarks from each used algorithm (ABTesting) are selected


    Otherwise, an equal amount of bookmarks is taken from each bookmark_group and concatenated into a list,
    which is then returned. The amount of bookmarks taken from each group can differ by 1, depending on whether the
    possible_bookmarks_to_return_count is equally dividable by the group count.

    """
    bookmarks_query = (
        Bookmark.query.filter_by(user_id=user.id)
        .filter_by(learned=False)
        .filter((Bookmark.fit_for_study > 0) | (Bookmark.starred == True))
        .join(BookmarkPriorityARTS, BookmarkPriorityARTS.bookmark_id == Bookmark.id)
        .join(UserWord, Bookmark.origin_id == UserWord.id)
        .filter(UserWord.language_id == user.learned_language_id)
        .order_by(BookmarkPriorityARTS.priority.desc())
    )

    bookmarks = bookmarks_query.all()

    # Group the bookmarks by their used priority algorithm in lists
    bookmark_groups = ABTesting.split_bookmarks_based_on_algorithm(bookmarks)
    if len(bookmarks) == 0:
        logger.info("Zero bookmarks to study")
        return []

    group_count = len(bookmark_groups)
    logger.info(f"Bookmark groups: {group_count}")
    if group_count == 0:
        return []

    # Select bookmarks from the algorithm groups
    bookmarks_to_return = []
    possible_bookmarks_to_return_count = min(desired_bookmarks_count, len(bookmarks))
    i = 0  # counter to select from different groups
    while possible_bookmarks_to_return_count != len(bookmarks_to_return):
        idx = i % len(bookmark_groups)
        if 0 < len(bookmark_groups[idx]):
            bookmarks_to_return.append(bookmark_groups[idx].pop(0))

        if i >= len(bookmarks):
            # no more bookmarks available...
            break
        i = i + 1

    return bookmarks_to_return


    Returns a list of bookmarks with the highest priorities
    An equal amount of bookmarks from each used algorithm (ABTesting) are selected


    Otherwise, an equal amount of bookmarks is taken from each bookmark_group and concatenated into a list,
    which is then returned. The amount of bookmarks taken from each group can differ by 1, depending on whether the
    possible_bookmarks_to_return_count is equally dividable by the group count.

    
Returns a list of bookmarks with the highest priorities
An equal amount of bookmarks from each used algorithm (ABTesting) are selected

Otherwise, an equal amount of bookmarks is taken from each bookmark_group and concatenated into a list,
which is then returned. The amount of bookmarks taken from each group can differ by 1, depending on whether the
possible_bookmarks_to_return_count is equally dividable by the group count.
Returns a list of bookmarks with the highest priorities An equal amount of bookmarks from each used algorithm ( ABTesting ) are selected Otherwise an equal amount of bookmarks is taken from each bookmark_group and concatenated into a list which is then returned . The amount of bookmarks taken from each group can differ by 1 depending on whether the possible_bookmarks_to_return_count is equally dividable by the group count .
def bookmarks_to_study(user, desired_bookmarks_count=10):
    bookmarks_query = (
        Bookmark.query.filter_by(user_id=user.id)
        .filter_by(learned=False)
        .filter((Bookmark.fit_for_study > 0) | (Bookmark.starred == True))
        .join(BookmarkPriorityARTS, BookmarkPriorityARTS.bookmark_id == Bookmark.id)
        .join(UserWord, Bookmark.origin_id == UserWord.id)
        .filter(UserWord.language_id == user.learned_language_id)
        .order_by(BookmarkPriorityARTS.priority.desc())
    )
    bookmarks = bookmarks_query.all()
    bookmark_groups = ABTesting.split_bookmarks_based_on_algorithm(bookmarks)
    if len(bookmarks) == 0:
        logger.info("Zero bookmarks to study")
        return []
    group_count = len(bookmark_groups)
    logger.info(f"Bookmark groups: {group_count}")
    if group_count == 0:
        return []
    bookmarks_to_return = []
    possible_bookmarks_to_return_count = min(desired_bookmarks_count, len(bookmarks))
    i = 0  
    while possible_bookmarks_to_return_count != len(bookmarks_to_return):
        idx = i % len(bookmark_groups)
        if 0 < len(bookmark_groups[idx]):
            bookmarks_to_return.append(bookmark_groups[idx].pop(0))
        if i >= len(bookmarks):
            break
        i = i + 1
    return bookmarks_to_return
def bookmarks_to_study ( user , desired_bookmarks_count = 10 ) : bookmarks_query = ( Bookmark . query . filter_by ( user_id = user . id ) . filter_by ( learned = False ) . filter ( ( Bookmark . fit_for_study > 0 ) | ( Bookmark . starred == True ) ) . join ( BookmarkPriorityARTS , BookmarkPriorityARTS . bookmark_id == Bookmark . id ) . join ( UserWord , Bookmark . origin_id == UserWord . id ) . filter ( UserWord . language_id == user . learned_language_id ) . order_by ( BookmarkPriorityARTS . priority . desc ( ) ) ) bookmarks = bookmarks_query . all ( ) bookmark_groups = ABTesting . split_bookmarks_based_on_algorithm ( bookmarks ) if len ( bookmarks ) == 0 : logger . info ( "Zero bookmarks to study" ) return [ ] group_count = len ( bookmark_groups ) logger . info ( f"Bookmark groups: {group_count}" ) if group_count == 0 : return [ ] bookmarks_to_return = [ ] possible_bookmarks_to_return_count = min ( desired_bookmarks_count , len ( bookmarks ) ) i = 0 while possible_bookmarks_to_return_count != len ( bookmarks_to_return ) : idx = i % len ( bookmark_groups ) if 0 < len ( bookmark_groups [ idx ] ) : bookmarks_to_return . append ( bookmark_groups [ idx ] . pop ( 0 ) ) if i >= len ( bookmarks ) : break i = i + 1 return bookmarks_to_return
Returns a list of bookmarks with the highest priorities
An equal amount of bookmarks from each used algorithm (ABTesting) are selected
Returns a list of bookmarks with the highest priorities An equal amount of bookmarks from each used algorithm ( ABTesting ) are selected
"""

    Returns a list of bookmarks with the highest priorities
    An equal amount of bookmarks from each used algorithm (ABTesting) are selected


    Otherwise, an equal amount of bookmarks is taken from each bookmark_group and concatenated into a list,
    which is then returned. The amount of bookmarks taken from each group can differ by 1, depending on whether the
    possible_bookmarks_to_return_count is equally dividable by the group count.

    """ # Group the bookmarks by their used priority algorithm in lists # Select bookmarks from the algorithm groups # counter to select from different groups # no more bookmarks available...
user
desired_bookmarks_count