
    >iN                     2   d dl mZmZ  G d de      Z G d de      Z G d de      Z G d d	e      Z G d
 de      Z G d de      Z G d de      Z	 G d de      Z
 G d de      Z G d de      Z G d de      Z G d de      Z G d de      Zy)   )ReducerSortDirectionc                        e Zd Z fdZ xZS )FieldOnlyReducerc                 2    t         |   |       || _        y N)super__init___fieldselffield	__class__s     z/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/redis/commands/search/reducers.pyr
   zFieldOnlyReducer.__init__   s        )__name__
__module____qualname__r
   __classcell__r   s   @r   r   r      s     r   r   c                   &     e Zd ZdZdZ fdZ xZS )countz3
    Counts the number of results in the group
    COUNTc                 "    t         |           y r   r	   r
   )r   r   s    r   r
   zcount.__init__   s    r   r   r   r   __doc__NAMEr
   r   r   s   @r   r   r   
   s     D r   r   c                   &     e Zd ZdZdZ fdZ xZS )sumzS
    Calculates the sum of all the values in the given fields within the group
    SUMc                 $    t         |   |       y r   r   r   s     r   r
   zsum.__init__       r   r   r   s   @r   r    r            D   r   r    c                   &     e Zd ZdZdZ fdZ xZS )minzK
    Calculates the smallest value in the given field within the group
    MINc                 $    t         |   |       y r   r   r   s     r   r
   zmin.__init__'   r#   r   r   r   s   @r   r&   r&       r$   r   r&   c                   &     e Zd ZdZdZ fdZ xZS )maxzJ
    Calculates the largest value in the given field within the group
    MAXc                 $    t         |   |       y r   r   r   s     r   r
   zmax.__init__2   r#   r   r   r   s   @r   r*   r*   +   r$   r   r*   c                   &     e Zd ZdZdZ fdZ xZS )avgzG
    Calculates the mean value in the given field within the group
    AVGc                 $    t         |   |       y r   r   r   s     r   r
   zavg.__init__=   r#   r   r   r   s   @r   r.   r.   6   r$   r   r.   c                   &     e Zd ZdZdZ fdZ xZS )tolistz6
    Returns all the matched properties in a list
    TOLISTc                 $    t         |   |       y r   r   r   s     r   r
   ztolist.__init__H   r#   r   r   r   s   @r   r2   r2   A        D   r   r2   c                   &     e Zd ZdZdZ fdZ xZS )count_distinctzs
    Calculate the number of distinct values contained in all the results in
    the group for the given field
    COUNT_DISTINCTc                 $    t         |   |       y r   r   r   s     r   r
   zcount_distinct.__init__T   r#   r   r   r   s   @r   r7   r7   L   s    
 D   r   r7   c                       e Zd ZdZdZy)count_distinctishz
    Calculate the number of distinct values contained in all the results in the
    group for the given field. This uses a faster algorithm than
    `count_distinct` but is less accurate
    COUNT_DISTINCTISHN)r   r   r   r   r    r   r   r;   r;   X   s     Dr   r;   c                   &     e Zd ZdZdZ fdZ xZS )quantilezp
    Return the value for the nth percentile within the range of values for the
    field within the group.
    QUANTILEc                 F    t         |   |t        |             || _        y r   )r	   r
   strr   )r   r   pctr   s      r   r
   zquantile.__init__j   s    C)r   r   r   s   @r   r?   r?   b   s    
 D r   r?   c                   &     e Zd ZdZdZ fdZ xZS )stddevzG
    Return the standard deviation for the values within the group
    STDDEVc                 $    t         |   |       y r   r   r   s     r   r
   zstddev.__init__v   r#   r   r   r   s   @r   rE   rE   o   r5   r   rE   c                   &     e Zd ZdZdZ fdZ xZS )first_valuezR
    Selects the first value within the group according to sorting parameters
    FIRST_VALUEc                    g }t        |      dk(  r2t        |d   t              rt        |d   t              r |d   |      g}|D ]  }||j
                  |j                  gz  } |g}|r	|dg|z   z  }t        |    |  || _	        y)a  
        Selects the first value of the given field within the group.

        ### Parameter

        - **field**: Source field used for the value
        - **byfields**: How to sort the results. This can be either the
            *class* of `aggregation.Asc` or `aggregation.Desc` in which
            case the field `field` is also used as the sort input.

            `byfields` can also be one or more *instances* of `Asc` or `Desc`
            indicating the sort order for these fields
        r       BYN)
len
isinstancetype
issubclassr   r   	DIRSTRINGr	   r
   r   )r   r   byfields	fieldstrsfargsr   s         r   r
   zfirst_value.__init__   s     	MQ8A;-8A;6#E*+H 	0A!''1;;//I	0 wTFY&&D$r   r   r   s   @r   rI   rI   z   s     D r   rI   c                   &     e Zd ZdZdZ fdZ xZS )random_samplezT
    Returns a random sample of items from the dataset, from the given property
    RANDOM_SAMPLEc                 F    |t        |      g}t        |   |  || _        y)z
        ### Parameter

        **field**: Field to sample from
        **size**: Return this many items (can be less)
        N)rB   r	   r
   r   )r   r   sizerV   r   s       r   r
   zrandom_sample.__init__   s'     s4y!$r   r   r   s   @r   rX   rX      s     D	 	r   rX   N)aggregationr   r   r   r   r    r&   r*   r.   r2   r7   r;   r?   rE   rI   rX   r=   r   r   <module>r]      s    /w G  
   
   
   
     	 % 	 ( 
w 
   %' %PG r   