
    xh                         S SK r S SKJr  S SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJrJrJr   " S S	\\5      r " S
 S\\R                   5      r " S S\5      rg)    N)	timedelta)SearchVectorField)models)PostgresPartitionedModel)PostgresPartitioningMethod)AggregationModelCreatedModelSoftDeleteModelc                       \ rS rSr\R
                  " SS9r\R                  " S\R                  S9r	\R
                  " SS9r
\R
                  " SSS9r\R                  " \S	9r\" SS
S9r " S S5      rS rSrg)TransactionGroup   i   )
max_lengthzprojects.Project	on_delete   T)r   blankdefaultF)nulleditablec                   <    \ rS rSr\R
                  " / SQSS9/rSrg)TransactionGroup.Meta   )transactionprojectopmethod$unique_transaction_project_op_method)fieldsname N)__name__
__module____qualname____firstlineno__r   UniqueConstraintconstraints__static_attributes__r!        /code/apps/performance/models.pyMetar      s    ##A;
r)   r+   c                     U R                   $ N)r   selfs    r*   __str__TransactionGroup.__str__   s    r)   r!   N)r"   r#   r$   r%   r   	CharFieldr   
ForeignKeyCASCADEr   r   r   	JSONFielddicttagsr   search_vectorr+   r0   r(   r!   r)   r*   r   r      sv    ""d3K 2fnnMG			S	)BD9FD)D%4%@M
 
 r)   r   c                      \ rS rSr\R
                  " SSS5      r\R                  " \R                  SS9r
\R                  " S\R                  S9r\R                  " \\R                  S9r\R                  " S	S
9r\R"                  " S	SS9r\R"                  " S	S	SS9r\R(                  " SS9r\R(                  " \S9r " S S5      r " S S5      rS r\S\S-  4S j5       r\S\S-  4S j5       rSr g)TransactionEvent    event_idorganizationstart_timestampF)r   r   organizations_ext.Organizationr   T)db_indexz?Datetime reported by client as the time the measurement started)r@   	help_textz@Datetime reported by client as the time the measurement finished)r   r   rA   z%General event data that is searchable)rA   r   c                       \ rS rSrS/rSrg)TransactionEvent.Meta6   z-start_timestampr!   N)r"   r#   r$   r%   orderingr(   r!   r)   r*   r+   rC   6   s
    &'r)   r+   c                   2    \ rS rSr\R
                  rS/rSrg)!TransactionEvent.PartitioningMeta9   r>   r!   N)	r"   r#   r$   r%   r   RANGEr   keyr(   r!   r)   r*   PartitioningMetarG   9   s    +11 !r)   rK   c                 ,    [        U R                  5      $ r-   )strtrace_idr.   s    r*   r0   TransactionEvent.__str__=   s    4==!!r)   returnNc                 X    U R                   (       a  U R                   U R                  -
  $ g r-   )	timestampr>   r.   s    r*   durationTransactionEvent.duration@   s#    >>>>D$8$888 r)   c                     U R                   =n(       a/  UR                  S-  UR                  S-  -   UR                  S-  -   $ g)z5Optimized method for getting duration in millisecondsi \&i  N)rS   dayssecondsmicroseconds)r/   rS   s     r*   duration_msTransactionEvent.duration_msE   sO     }}$8$+##d*,''4/0 %r)   r!   )!r"   r#   r$   r%   r   CompositePrimaryKeypk	UUIDFielduuiduuid4r<   r3   r4   r=   r   grouprN   DateTimeFieldr>   rR   r5   datar6   r7   r+   rK   r0   propertyr   rS   intrY   r(   r!   r)   r*   r:   r:       s   		#	#J@Q	RB

UCH$$(FNNL .&..IE.H**SO $$TI
 &MND D)D( (" "" 9)d* 9 9 S4Z  r)   r:   c                   <   \ rS rSrSr\R                  " SSS5      r\R                  " \	\R                  S9r\R                  " S\R                  S9r\R                  " SS	S
9r\R                  " SSS
9r\R                   " \SS
9r " S S\R(                  5      rSrg)TransactionGroupAggregateP   z@Count the number of events for a transaction group per time unitr`   r=   dater   r?   r   zBSum of all transaction durations (in ms) for calculating the mean.)r   rA   z@Sum of squares of durations, for calculating standard deviation.z=Stores a fixed-bucket histogram for percentile approximation.c                       \ rS rSrSrg)*TransactionGroupAggregate.PartitioningMetae   r!   N)r"   r#   r$   r%   r(   r!   r)   r*   rK   rj   e   s    r)   rK   r!   N)r"   r#   r$   r%   __doc__r   r[   r\   r3   r   r4   r`   r=   PositiveBigIntegerFieldtotal_durationsum_of_squares_durationr5   r6   	histogramr   rK   r(   r!   r)   r*   rf   rf   P   s    J		#	#G^V	DB.&..IE$$(FNNL 33VN %<<T   QI
+<< r)   rf   )r^   datetimer   django.contrib.postgres.searchr   	django.dbr   psql_partition.modelsr   psql_partition.typesr   glitchtip.base_modelsr   r	   r
   r   Modelr:   rf   r!   r)   r*   <module>rx      sL      <  : ; Q Q |_  (-/ -` 0 r)   