Files
boc/iom/sync/__pycache__/mobile_adapter.cpython-39.pyc
T

73 lines
8.2 KiB
Plaintext
Raw Normal View History

a
ÒL>j/.ã@sLdZddlmZmZmZddlmZGdddƒZddZedkrHeƒd S)
u
Mobile API Adapter — Optimizes IOM data for quiXzoom mobile app
Mobile-first: iPhone-first, always. One hand, one thumb, three seconds.
é)ÚDictÚListÚOptional)Údatetimec@eZdZdZddZeedœddZeedœdd „Zeed
œd d Zeed
œddZ eedœddZ
e e dœddZ e
e dœddZee dœddZee dœddZee dœddZeeedœd d!„Zeeed
œd"d#„Zee dœd$d%„Zd&S)'Ú
MobileAdapterz&Adapts IOM data for mobile consumptioncCs
d|_dS)NiÈ)Zmax_payload_size)Úself©rú:/home/bernt/.openclaw/workspace/iom/sync/mobile_adapter.pyÚ__init__
szMobileAdapter.__init__)Ú observationÚreturnc Cs~| d¡| d¡| | dd¡¡| dd¡| | dd¡¡| d¡| d¡| dd ¡d
œ| d ¡t| d g¡ƒ| d
¡ddœ
S)zd
Adapt observation for mobile app
Strip unnecessary fields, optimize images
ÚidÚgoidÚÚoverall_conditionéZlatitudeZ longitudeÚaddressÚUnknown)ÚlatÚlngrZ
thumbnail_urlÚfindingsÚ timestampT)
r
rÚtypeÚ conditionZcondition_labelÚlocationZ thumbnailZfindings_countrÚsynced)ÚgetÚ_get_mobile_typeÚ_get_condition_labelÚlen)rr rrr Úadapt_observations

ýòzMobileAdapter.adapt_observation)Ú
rgi_resultr c
C| d¡t| dd¡ƒ| | dd¡¡| d¡| dd¡dkdt| di¡ di¡ d d¡ƒd
d œd t| di¡ d
i¡ d d¡ƒdd œdt| di¡ di¡ d d¡ƒdd œg| |¡| |¡dœS)zU
Adapt RGI for mobile display
Simplified, visual, actionable
rÚ overall_rgirÚcontradiction_levelé2ÚPhysicalÚ subscoresÚphysical_reality_gapÚscoreZbuilding)Únamer(ZiconÚSafetyÚsafety_reality_gapÚshieldÚEconomicÚeconomic_reality_gapÚdollar)rÚ rgi_scoreÚ rgi_colorÚlevelÚalertÚ
dimensionsZtop_contradictionÚinsight)rÚroundÚ_get_rgi_colorÚ_get_top_contradictionÚ_generate_insight)rr!rrr Úadapt_rgi_for_mobile&s*ýýýõâz"MobileAdapter.adapt_rgi_for_mobile)Ú
rcs_resultr c Csf| d¡t| dd¡ƒ| | dd¡¡| | dd¡¡| |¡| dd¡| dd¡| dd¡dœdœS) zM
Adapt RCS for mobile display
Alert-style, immediate
rÚ rcs_scorerÚcontradiction_countZcritical_countZ major_count)ÚtotalÚcriticalÚmajor)rr<Ú alert_levelZ alert_colorÚ strongestÚsummary)rr6Ú_get_alert_levelÚ_get_alert_colorÚ_get_strongest_contradiction)rr;rrr Úadapt_rcs_for_mobileLs


ýöz"MobileAdapter.adapt_rcs_for_mobile)Ú
uli_resultr c C| di¡}| d¡t| dd¡ƒ| dd¡dt| di¡ dd¡ƒd | di¡ d
d ¡d œd
t| di¡ dd¡ƒd| di¡ d
d ¡d œdt| di¡ dd¡ƒd| di¡ d
d ¡d œg| dd¡| dd¡dœS)zJ
Adapt ULI for mobile
Visual layer representation
ÚlayersrÚulirÚ
reality_countZFormalÚformalr(z#4A90E2ÚdominantF)r)r(ÚcolorrMZ
FunctionalÚ
functionalz#F5A623ZInformalÚinformalz#D0021BÚdominant_layerÚunknownÚinterpretationr)rÚ uli_scorerKrIrQrS)rr6)rrHrIrrr Úadapt_uli_for_mobilebs. 
üüüó

áz"MobileAdapter.adapt_uli_for_mobile)Údatar c Cs”ddt| dd¡ƒ| dd¡| | dd¡¡dœddt| dd¡ƒ| d d¡| | dd¡¡d
œd d t| d d¡ƒ| d
d¡ddœgt ¡ ¡dœS)z]
Adapt dashboard data for mobile summary view
Cards-style, swipeable
Úrgiz Reality GaprZ rgi_trendÚstable)rÚtitler(ÚtrendrNÚrcsZContradictionsr=)rrYr(ÚcountrNrJz Urban LayersrKz#9013FE)rrYr(Z realitiesrN)ZcardsZ last_updated)r6rr7rErÚutcnowÚ isoformat)rrVrrr Úadapt_dashboard_summarys*
û
û
ûñ
èz%MobileAdapter.adapt_dashboard_summary)rr c CsH| d¡}t|ƒdkrDddddddd d
d d d
œ
}| |d|d¡SdS)z"Get mobile-friendly type from GOIDúZWindowZRoadZSignZLightZChargerZPavementZFenceÚPipeZCabinetZAntenna)
ÚWINZRODZSGNZLIGZCHAZPAVZFENZPIPZCABZANTrr)Úsplitrr)rrÚpartsÚtype_maprrr r«s
 ö zMobileAdapter._get_mobile_type)rr cCsddddddœ}| |d¡S)z"Get human-readable condition labelZ ExcellentZGoodZFairZPoorZCritical)éérraér©r)rrÚlabelsrrr r¾sûz"MobileAdapter._get_condition_label)r(r cCs8|dkr dS|dkrdS|dkr$dS|dkr0dSd Sd
S) zGet color for RGI scoreéú#4CAF50é(z#8BC34Aé<ú#FFC107éPú#FF9800ú#F44336Nr©rr(rrr r7ÉszMobileAdapter._get_rgi_colorcCs,|dkr dS|dkrdS|dkr$dSdSdS) zGet alert levelé
ÚlowéÚmediumr$Úhighr?Nrrtrrr rDÖszMobileAdapter._get_alert_levelcCs,|dkr dS|dkrdS|dkr$dSdSdS) zGet alert colorrurmrwrpr$rrrsNrrtrrr rEászMobileAdapter._get_alert_colorcCsD| dg¡}|r@|d}| d¡| d¡| dd¡ddd œSdS)
z Get top contradiction for mobileÚcontradictionsrrÚseverityÚ descriptionrNéd©rr{r|rj)rr!rzÚtoprrr r8ìs ýz$MobileAdapter._get_top_contradictioncCsD| dg¡}|r@|d}| d¡| d¡| dd¡ddd œSdS)
z&Get strongest contradiction for mobileÚstrongest_contradictionsrrr{r|rNrqr~rj)rr;rBrrrr rFøs ýz*MobileAdapter._get_strongest_contradictioncCsD| dd¡}|dkrdS|dkr$dS|dkr0dS|d kr<d
Sd Sd S)