
    /i                        d dl m Z  d dlmZmZ d dlmZ d dlmZ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 G d d e      Z G d! d"e      Z G d# d$e      Z G d% d&e      Zy')(    )datetime)OptionalList)UUID)	BaseModelField
ConfigDictc                       e Zd ZU dZ edd      Zeed<    edd      Zeed<    edd      Z	eed	<    edd
      Z
eed<    edd      Zeed<    ed      Zy)ActiveViolationsKPIzKPI card for active violations..z Total count of active violationsdescriptiontotal_active_violationsz+Total detection count across all violationstotal_detectionsz(Number of unique vendors with violationsoffending_vendors_countz)Number of unique products with violationsaffected_products_countcriticalz0Status indicator: 'critical', 'active', or 'low'defaultr   statusTfrom_attributesN)__name__
__module____qualname____doc__r   r   int__annotations__r   r   r   r   strr	   model_config     ;/var/www/html/marco-python-backend/app/schemas/dashboard.pyr   r      sm    )#(:\#]S]!#3`aca#(:d#eSe#(:e#fSf
8jkFCkd3Lr!   r   c                   B    e Zd ZU dZ edd      Zeed<    ed      Z	y)	MonitoredProductsKPIz KPI card for monitored products..z"Total number of monitored productsr   total_monitored_productsTr   N)
r   r   r   r   r   r%   r   r   r	   r   r    r!   r"   r$   r$      s"    *$)#;_$`c`d3Lr!   r$   c                   B    e Zd ZU dZ edd      Zeed<    ed      Z	y)	AveragePriceDiscountKPIz)KPI card for average discount percentage..z+Average discount % across active violationsr   average_discount_percentageTr   N)
r   r   r   r   r   r(   floatr   r	   r   r    r!   r"   r'   r'      s"    3).s@m)nnd3Lr!   r'   c                   B    e Zd ZU dZeed<   eed<   eed<    ed      Z	y)
KPISummaryz!KPI summary section of dashboard.active_violationsmonitored_productsaverage_discountTr   N)
r   r   r   r   r   r   r$   r'   r	   r   r    r!   r"   r+   r+   !   s!    +**,,--d3Lr!   r+   c                   `    e Zd ZU dZ edd      Zeed<    edd      Ze	ed<    e
d	      Zy
)TrendDataPointz1Single data point for the 30-day violation trend..zDate in YYYY-MM-DD formatr   datez!Number of violations on this dateviolation_countTr   N)r   r   r   r   r   r1   r   r   r2   r   r	   r   r    r!   r"   r0   r0   +   s3    ;c'BCD#C 2UVOSVd3Lr!   r0   c                   f    e Zd ZU dZ edd      Zee   ed<    edd      Z	e
ed	<    ed
      Zy)ViolationTrendChartz"30-day violation trend chart data..z1List of violation counts per day for last 30 daysr   
trend_datazLast 30 DayszPeriod labelr   period_labelTr   N)r   r   r   r   r   r5   r   r0   r   r6   r   r	   r   r    r!   r"   r4   r4   3   s7    ,',S>q'rJ^$rn.QL#Qd3Lr!   r4   c                   `    e Zd ZU dZ edd      Zeed<    edd      Ze	ed<    e
d	      Zy
)MarketplaceAnalysisz*Data for marketplace with most violations..zName of the marketplacer   marketplace_namez&Total violations from this marketplacer2   Tr   N)r   r   r   r   r   r9   r   r   r2   r   r	   r   r    r!   r"   r8   r8   <   s4    4!#3LMcM 2Z[OS[d3Lr!   r8   c                   `    e Zd ZU dZ edd      Zeed<    edd      Ze	ed<    e
d	      Zy
)VendorAnalysiszData for most offending vendor..Name of the vendorr   vendor_namez%Number of violations from this vendorr2   Tr   N)r   r   r   r   r   r=   r   r   r2   r   r	   r   r    r!   r"   r;   r;   D   s3    )S.BCKC 2YZOSZd3Lr!   r;   c                   `    e Zd ZU dZ edd      Zeed<    edd      Ze	ed<    e
d	      Zy
)ProductAnalysiszData for most affected product..Name of the productr   product_namez%Number of violations for this productr2   Tr   N)r   r   r   r   r   rA   r   r   r2   r   r	   r   r    r!   r"   r?   r?   L   s3    )c/DEL#E 2YZOSZd3Lr!   r?   c                       e Zd ZU dZ edd      Zeed<    edd      Ze	ed<    edd      Z
e	ed	<    edd
      Ze	ed<    ed      Zy)HighestDiscountAnalysisz#Data for highest discount detected..z)Name of the product with highest discountr   rA   z$Highest discount percentage detectedhighest_discount_percentagezManufacturer Suggested PricemspzActual scraped pricescraped_priceTr   N)r   r   r   r   r   rA   r   r   rD   r)   rE   rF   r	   r   r    r!   r"   rC   rC   T   sX    -c/Z[L#[).s@f)ggs(FGCG 2HIM5Id3Lr!   rC   c                   ~    e Zd ZU dZ edd      Zeed<    edd      Ze	ed	<    edd
      Z
eed<    ed      Zy)FinancialImpactAnalysisz$Data for estimated financial impact..z"Total estimated impact in currencyr   total_estimated_impactUSDz Currency of the financial impactr   currencyz+Number of violations contributing to impactr2   Tr   N)r   r   r   r   r   rI   r)   r   rK   r   r2   r   r	   r   r    r!   r"   rH   rH   ^   sF    .$)#;_$`E`%5WXHcX 2_`OS`d3Lr!   rH   c                       e Zd ZU dZ edd      Zee   ed<    edd      Z	ee
   ed<    edd      Zee   ed	<    edd
      Zee   ed<    edd      Zeed<    ed      Zy)ViolationAnalysisz(Violation analysis section of dashboard.Nz Marketplace with most violationsr    marketplace_with_most_violationszVendor with most violationsmost_offending_vendorzProduct with most violationsmost_affected_productzProduct with highest discounthighest_discount_detected.zEstimated financial impactfinancial_impactTr   )r   r   r   r   r   rN   r   r8   r   rO   r;   rP   r?   rQ   rC   rR   rH   r	   r   r    r!   r"   rM   rM   g   s    2FKD  _A  GB$h/B&C  B6;DNk6l8N3l7<TOm7n8O4nCH[zC{x(?@{05cGc0d-dd3Lr!   rM   c                   r   e Zd ZU dZeed<    edd      Zeed<    edd      Z	e
e   ed	<    edd
      Ze
e   ed<    edd      Zeed<    edd      Zeed<    edd      Ze
e   ed<    edd      Ze
e   ed<    edd      Zeed<    edd      Zeed<    edd      Zeed<    ed      Zy)RecentViolationItemz2A single violation item in recent violations list.id.r@   r   rA   Nz%Marketplace where violation was foundmarketplacer<   r=   zCurrent scraped pricecurrent_pricez#Target Manufacturer Suggested Price
target_mspz(Difference between MSP and scraped priceprice_differencez3Percentage difference between MSP and scraped pricepercentage_differenceopenz)Status of violation: 'open' or 'notified'r   r   z Date when violation was detectedviolation_datezURL where violation was foundurlTr   )r   r   r   r   r   r   r   rA   r   rV   r   r=   rW   r)   rX   rY   rZ   r   r\   r   r]   r	   r   r    r!   r"   rT   rT   s   s    <Hc/DEL#E!&t9`!aK#a!&t9M!NK#N 2IJM5Jc/TUJU(-d@j(khuok-24Ez-{8E?{4_`FC`$S6XYNHYS&EFCFd3Lr!   rT   c                   f    e Zd ZU dZ edd      Zee   ed<    edd      Z	e
ed<    ed	      Zy
)RecentViolationsPanelz'Recent violations section of dashboard..z<List of most recent violations (typically last N violations)r   recent_violationszTotal violations counttotal_violationsTr   N)r   r   r   r   r   r`   r   rT   r   ra   r   r	   r   r    r!   r"   r_   r_      sE    138  KI  4Jt/0  J!#3KLcLd3Lr!   r_   c                       e Zd ZU dZ edd      Zeed<    edd      Ze	ed<    edd      Z
eed	<    edd
      Zeed<    edd      Zeed<    ed      Zy)DashboardResponsez4Complete dashboard response containing all sections..zKPI summary cardsr   kpi_summaryz30-day violation trend chartviolation_trendzViolation analysis insightsviolation_analysiszRecent violations panelr`   z(Timestamp of last dashboard data refreshlast_refreshed_atTr   N)r   r   r   r   r   rd   r+   r   re   r4   rf   rM   r`   r_   rg   r   r	   r   r    r!   r"   rc   rc      so    >#C5HIKI+0B`+aO(a,1#C`,a)a/4SF_/`,`"'9c"dxdd3Lr!   rc   c                   B    e Zd ZU dZ edd      Zeed<    ed      Z	y)	DashboardRefreshRequestz5Request payload for dashboard refresh (can be empty).Fz&Whether to trigger scraping on refreshr   trigger_scrapingTr   N)
r   r   r   r   r   rj   boolr   r	   r   r    r!   r"   ri   ri      s"    ?"5>fgdgd3Lr!   ri   c                       e Zd ZU dZ edd      Zeed<    edd      Ze	ed<    edd	      Z
ee   ed
<    ed      Zy)DashboardRefreshResponsezResponse for dashboard refresh..zStatus messager   messagezWhether refresh is in progressis_refreshingNz)Estimated time for next data availabilitynext_refresh_estimateTr   )r   r   r   r   r   rn   r   r   ro   rk   rp   r   r   r	   r   r    r!   r"   rm   rm      sK    )*:;GS;1QRM4R05dHs0t8H-td3Lr!   rm   N)r   typingr   r   uuidr   pydanticr   r   r	   r   r$   r'   r+   r0   r4   r8   r;   r?   rC   rH   rM   rT   r_   rc   ri   rm   r    r!   r"   <module>rt      s     !  1 14) 449 44i 44 44Y 44) 44) 44Y 44i 44i 44i 44	 44) 4"4I 44	 44i 44y 4r!   