
    g`                    0   d dl mZ d dlmZ d dlZd dlmZ d dlmZ  ed       G d d	             Z	 ed       G d
 d             Z
 ed       G d d             Z ed       G d d             Z ed       G d de             Z G d de      Zy)    )annotations)AnyN)	dataclass)MessageToDictT)frozenc                  &    e Zd ZU dZdZded<   d Zy)ExplainOptionsa  
    Explain options for the query.
    Set on a query object using the explain_options attribute at query
    construction time.

    :type analyze: bool
    :param analyze: Optional. Whether to execute this query. When false
    (the default), the query will be planned, returning only metrics from the
    planning stages. When true, the query will be planned and executed,
    returning the full query results along with both planning and execution
    stage metrics.
    Fboolanalyzec                    d| j                   iS )Nr   )r   selfs    /var/www/html/FastMealFinder_FlaskServer-InitialRelease/venv/lib/python3.12/site-packages/google/cloud/firestore_v1/query_profile.py_to_dictzExplainOptions._to_dict)   s    4<<((    N)__name__
__module____qualname____doc__r   __annotations__r    r   r   r	   r	      s     GT)r   r	   c                      e Zd ZU dZded<   y)PlanSummaryz
    Contains planning phase information about a query.`

    :type indexes_used: list[dict[str, Any]]
    :param indexes_used: The indexes selected for this query.
    zlist[dict[str, Any]]indexes_usedNr   r   r   r   r   r   r   r   r   r   -   s     '&r   r   c                  :    e Zd ZU dZded<   ded<   ded<   ded<   y	)
ExecutionStatsa  
    Execution phase information about a query.

    Only available when explain_options.analyze is True.

    :type results_returned: int
    :param results_returned: Total number of results returned, including
        documents, projections, aggregation results, keys.
    :type execution_duration: datetime.timedelta
    :param execution_duration: Total time to execute the query in the backend.
    :type read_operations: int
    :param read_operations: Total billable read operations.
    :type debug_stats: dict[str, Any]
    :param debug_stats: Debugging statistics from the execution of the query.
        Note that the debugging stats are subject to change as Firestore evolves
    intresults_returnedzdatetime.timedeltaexecution_durationread_operationszdict[str, Any]debug_statsNr   r   r   r   r   r   9   s!    " **r   r   c                  >    e Zd ZU dZded<   ed        Zedd       Zy)ExplainMetricsa  
    ExplainMetrics contains information about the planning and execution of a query.

    When explain_options.analyze is false, only plan_summary is available.
    When explain_options.analyze is true, execution_stats is also available.

    :type plan_summary: PlanSummary
    :param plan_summary: Planning phase information about the query.
    :type execution_stats: ExecutionStats
    :param execution_stats: Execution phase information about the query.
    r   plan_summaryc           
        t        | j                  d      }t        |j                  di       j                  dg             }d|v r|j                  di       }t	        t        |j                  dd            | j                  j                  t        |j                  d	d            |j                  d
i             }t        ||      S t        |      S )NT)preserving_proto_field_namer%   r   )r   execution_statsr   r   r!   r"   )r   r    r!   r"   )r%   _execution_stats)r%   )
r   _pbr   getr   r   r(   r    _ExplainAnalyzeMetricsr$   )
metrics_pb	dict_reprr%   
stats_dictr(   s        r   _from_pbzExplainMetrics._from_pbb   s    !*..dS	""~r:>>~rR
 	)"'8"=J,!$Z^^4F%J!K#-#=#=#P#P #JNN3Da$H I&NN="=	O *)O  "|<<r   c                    t        d      )NzAexecution_stats not available when explain_options.analyze=False.)QueryExplainErrorr   s    r   r(   zExplainMetrics.execution_statsv   s    O
 	
r   Nreturnr   )	r   r   r   r   r   staticmethodr0   propertyr(   r   r   r   r$   r$   R   s5    
 = =& 
 
r   r$   c                  8    e Zd ZU dZded<   ded<   edd       Zy)	r,   z|
    Subclass of ExplainMetrics that includes execution_stats.
    Only available when explain_options.analyze is True.
    r   r%   r   r)   c                    | j                   S )N)r)   r   s    r   r(   z&_ExplainAnalyzeMetrics.execution_stats   s    $$$r   Nr3   )r   r   r   r   r   r6   r(   r   r   r   r,   r,   }   s'    
 $$% %r   r,   c                      e Zd ZdZy)r2   zW
    Error returned when there is a problem accessing query profiling information.
    N)r   r   r   r   r   r   r   r2   r2      s     	r   r2   )
__future__r   typingr   datetimedataclassesr   google.protobuf.json_formatr   r	   r   r   r$   r,   	Exceptionr2   r   r   r   <module>r@      s    #   ! 5 $) ) )( $' ' ' $     0 $'
 '
 '
T $%^ % %		 	r   