
    ph	                         d Z ddlmZmZmZmZmZ deeeef   ef   fdZ	deeeef   ef   dededeeeef   ef   fdZ
deeeef   ef   defd	Zdeeeef   ef   dee   fd
Zdeeeef   ef   dee   fdZdeeeef   ef   defdZy)z4
Module containing wine match scoring functionality
    )DictListOptionalTupleSetreturnc                  
    i dfS )z
    Create a new keyword match data structure
    
    Returns:
        Tuple[Dict[str, int], int]: A tuple containing (matches dict, current score)
    r    r
       _/var/www/html/wine-match-dev/backend/winematch-backend/src/apps/wine_match/services/kw_match.pycreate_kw_matchr      s     q5Lr   matches_datawine_idscorec                 f    | \  }}||kD  r||i|fS ||k(  r|dkD  rt        |      }|||<   ||fS ||fS )a  
    Set or update match score for a wine ID
    
    Args:
        matches_data: Tuple containing (matches dict, current score)
        wine_id: The wine ID to score
        score: The score value
        
    Returns:
        Tuple[Dict[str, int], int]: Updated matches data
    r   )dict)r   r   r   matchescurrent_scorenew_matchess         r   set_match_scorer      s_     *G]}&&	-	EAI7m$GM)) %%r   c                 "    | \  }}t        |      S )z
    Get number of matches
    
    Args:
        matches_data: Tuple containing (matches dict, current score)
        
    Returns:
        int: Number of matches
    )lenr   r   _s      r   get_matches_sizer   +   s     JGQw<r   c                 >    | \  }}t        |j                               S )z
    Get list of match IDs
    
    Args:
        matches_data: Tuple containing (matches dict, current score)
        
    Returns:
        List[str]: List of match IDs
    )listkeysr   s      r   get_matchesr   9   s     JGQr   c                 R    | \  }}t        t        |j                               d      S )z
    Get first match ID if any exists
    
    Args:
        matches_data: Tuple containing (matches dict, current score)
        
    Returns:
        Optional[str]: First match ID or None if no matches
    N)nextiterr   r   s      r   get_first_matchr#   G   s%     JGQW\\^$d++r   c                     | \  }}|S )z
    Get current score
    
    Args:
        matches_data: Tuple containing (matches dict, current score)
        
    Returns:
        int: Current score
    r
   )r   r   r   s      r   	get_scorer%   U   s     HAuLr   N)__doc__typingr   r   r   r   r   strintr   r   r   r   r#   r%   r
   r   r   <module>r*      s   4 3tCH~s23 &%S#X(;"< &s &SV &[`aefiknfnaoqtat[u &65c3h)<#= #  eDcNC$78  T#Y  ,%S#X(;"< ,# ,E$sCx.#"56 3 r   