From 63004959292f531dd35a38a21fe064c75c241885 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 12 Dec 2025 16:57:06 -0500 Subject: [PATCH] priorite fonctionne de base a tester --- a faire | 15 ---------- .../process_course.cpython-313.pyc | Bin 5933 -> 6079 bytes .../__pycache__/regles.cpython-313.pyc | Bin 6061 -> 6197 bytes engine/engine_components/process_course.py | 8 +++--- engine/engine_components/regles.py | 26 ++++++++++-------- engine/info.txt | 19 ++++++++++++- 6 files changed, 37 insertions(+), 31 deletions(-) delete mode 100644 a faire diff --git a/a faire b/a faire deleted file mode 100644 index af7601d..0000000 --- a/a faire +++ /dev/null @@ -1,15 +0,0 @@ -Notes pour correction du moteur Python - -Les priorités ne fonctionnent pas. -La logique actuelle doit être revue. - -La validation des intervalles est mal faite. -Elle doit être basée directement sur l’heure pour obtenir un rapprochement plus uniforme. - -Les tours ne fonctionnent pas. -Le calcul du tour et du temps de tour doit être revu complètement. - -Concept général à corriger : -Lorsqu’une entrée est jugée « bonne », on doit l’écrire immédiatement dans la base de données, -avant d’appliquer n’importe quelle autre validation. -Parce que ces lectures doivent être conservées quoi qu’il arrive. \ No newline at end of file diff --git a/engine/engine_components/__pycache__/process_course.cpython-313.pyc b/engine/engine_components/__pycache__/process_course.cpython-313.pyc index 685dd63cd9bb6dc9bcd502655b9aae714e0218f8..7e61a6d1291c50c136f382408bac97208e82f634 100644 GIT binary patch delta 513 zcmZ3hw_l&{GcPX}0}#B-x5;Eu*~qt(nMs3v^GW7tCPur>s%%+IJkc^Bc@PNFnXJeu zViLg^svIg8DibOist~FY%52IBkuGInV94XklgN|IQw?Pfm16}82kU~!ApObnIpi7j zC-3KwS5ylY%u^3l(|~AVNEBjVkYk7zhjJN0)h7Sv5M@-KoXDv>`2Z(}yn3jTDLX{A zlo@D)MxJJ#R;Wg>pj89|L!#W|*_^7A|8cSjYldo>vO&}-Ft{`NK44&&d>d?rn4or^ zPM$83N6dg85eMm#*ACSQ)rFa_z!1t8tOznU1!$8yldsBTWiCrb$H}o=s*IMCo4FJj z)i*EYGGS(voqUV8Ur?YZwKzYgEH%EMC^Nq(v!rrz246Iz-sU5G_KZB-Y57ITsVVU# z`K3jZnFPXF^ni|=oG73?&HsC<8KoB|{M?{)(i4#4Qe+-29Z%oK(A_y2+Qtq5v*Wcy<5) delta 401 zcmdn5zgCa$GcPX}0}!ZM+GKuG-pIF;ndu4J=9A3POpG#{RoSwb>O+}BP+_K zl4N9>oX%y*C_i~2mnx(Az}-zFN#rjvlPEQ!%#{yhC;@SC=4L)YR%WITa+{q+vKhHV1bsD`&T6vw>Tlj5I+2kvf3laj6l2Zg HRPiVP#@a@P diff --git a/engine/engine_components/__pycache__/regles.cpython-313.pyc b/engine/engine_components/__pycache__/regles.cpython-313.pyc index c55b56dbf9b025cc5807f10cbe2b3177de5a9077..6f8434ddcc28806d2ce36455692e2bf7606cc56e 100644 GIT binary patch delta 1195 zcmZuvOKjX!6n)QQkAJZ}|1_P1I7tgLYDgxXNrQ%_NKMNxB>lJ+5m9lcGfpz<)DCa# zwq!#KixQB4>UGgY7OYS};+rC|L5jo%5JHw(q-a1;RxDUBqEUrdAl~zokE*`K)$x7r zoO|x|eSh@Rf^u6?BtXuA%lqr!T~XR_`^sOd2~#rIav6XM1Yj|0g5w;H!(^5>85I~p zF)~-0^G&J5jWd)BfDZ7-FoTaKg_j)JlyjXdsA&Mqi+4YOA)1m3ip)3>rAMdIvLSH< zJ6#0HAyNqH3X%Fhu43|}v}$&dsD(Pw|8(Zgmah`CQ2>kxYsBy|CJjT!d^~iVz?YaL zl<`2iw_vJ{W+V+@08=ZmyMVzODU&w<#RJ5X!8%eun7uw3=?4oipT<8k1zd`pf*<0G z%Bfh*_A2#;Rj=v$59qs_68Xg-is&o)41TW5tL&!Xfe(0RD>mUdj_de@F8L{6X~C^X&u>(%0Y(zGq7t zY)gO>E>B;YZUZK*-O{qJI&HxBacxeF3*@C7yO#fGCJ+y9Cq?cMZ0`iJ`sVQJ@arQN zr|w9gOZ!2H2dP7wCpV7-i4!*k6Ic0xecMD;4PpB+(@M2=wqES`m%>6W+jIt7~v#V^PaNSjKO~X49c1(Q8_sYx!Ok9VTzz z!?$A#Z~{LUe`h@8QU^#NAur$00UD+EV>Ilgp@_#5#cZgob(-~DA9Wginmo9UUrAJn zjb9Saz{C!c$nzc9os^x$hf}+HLbl>B*D9WEb#@cYlIsA!oSG)wZ&MDG!)e?lJ&`HE z9KMhlg1_Rm%t2!Rr_A&ox_RMnJ42w|A!;GiLdOYu7oZ86$YHa4Bx*re`29(|+O4xR F`!^9-DEI&X delta 1041 zcmZuvJ8aWX6n)QjY{#zcIB7}0B%!6WB`qmUp_Gq+QWl^9Jt7+6+|dOexLvGs``|sEiXzlOdaO$G_ysJRkz!!v{&qG7#$jg||723kxdfi!BI=2(b*eO-Ig@vCQ)jm0b?k9?3twVe z@qM-pKW7{8A9f4QbM5#k_oG87vlF&kX7i4VI5JsTu+Q37$+gRD(M4r(+;**#Q;v;4 z1rCa3K4-g`d=78o-%IOBHeF@$7;X{{*Di`6pn9R+x$e1`r|x>o?XF1J5#lMnB~S^7 zx>yMTIdr@AX5md^a<oU`M4E$m+G^<>b|#i$gyoP@~~zLZZH+0 z^1^HG?w#G^X(>-k;e@y@Sm!A%i<%IO;lpCbT7H)EULWVE_b;wp?A-tW diff --git a/engine/engine_components/process_course.py b/engine/engine_components/process_course.py index 5cb1dc4..d1b5090 100644 --- a/engine/engine_components/process_course.py +++ b/engine/engine_components/process_course.py @@ -90,7 +90,7 @@ def process_course(cur, cnx, con_id: int): rcourse_id = int(lec["rcourse_id"]) chr_loc = lec["chrinfo_location"] timestamp = Decimal(lec["chrinfo_time"]) - + max_id = max(max_id, rcourse_id) dt_utc = regles.ts_to_utc(timestamp) @@ -168,9 +168,9 @@ def process_course(cur, cnx, con_id: int): # ------------------------------------------------- # Règle de priorité # ------------------------------------------------- - #status, reason_code, reason_ref_id, forced_tour = resolve_priority( - # cur, cnx, detail_table, tp_id, dossard, timestamp, prio, det_id, tp_config - #) + status, reason_code, reason_ref_id, forced_tour = regles.resolve_priority( + cur, cnx, detail_table, tp_id, dossard, timestamp, prio, detail_id, tp_config + ) diff --git a/engine/engine_components/regles.py b/engine/engine_components/regles.py index 7d25981..ccea37a 100644 --- a/engine/engine_components/regles.py +++ b/engine/engine_components/regles.py @@ -14,7 +14,7 @@ def resolve_priority( dossard, new_timestamp, new_priority, - det_id, + detail_id, tp_config ): @@ -34,7 +34,7 @@ def resolve_priority( except: backup_window = 0 - log_debug(f"[resolve_priority] backup_window={backup_window}") + # ------------------------------------------------- # Si backup_window = 0 → toujours accepter @@ -49,11 +49,14 @@ def resolve_priority( SELECT detail_id, controller_priority, timestamp_read, tour FROM `{detail_table}` WHERE tp_id = %s - AND cla_info_dossard = %s - AND status = 1 - AND ABS(timestamp_read - %s) <= %s + AND cla_info_dossard = %s + AND status = 1 + AND detail_id <> %s + AND ABS(timestamp_read - %s) <= %s LIMIT 1 - """, (tp_id, dossard, str(new_timestamp), backup_window)) + """, (tp_id, dossard, detail_id, new_timestamp, backup_window)) + + row = cur.fetchone() @@ -61,6 +64,7 @@ def resolve_priority( # Aucun doublon → accepter # ------------------------------------------------- if not row: + log_debug(f"[resolve_priority] pas de doublon backup_window={backup_window}") return 1, None, None, None old_id = row["detail_id"] @@ -70,17 +74,17 @@ def resolve_priority( # ------------------------------------------------- # Comparaison des priorités # ------------------------------------------------- - + log_debug(f"[resolve_priority] detail_id={detail_id} old_id={old_id} backup_window={backup_window}") # Nouvelle lecture moins prioritaire → rejet if new_priority > old_priority: - return 0, "LOWER_PRIORITY", det_id, None + return 0, "LOWER_PRIORITY", detail_id, None # Nouvelle lecture plus prioritaire → remplacer if new_priority < old_priority: - + cur.execute(f""" UPDATE `{detail_table}` SET @@ -88,7 +92,7 @@ def resolve_priority( reason_code = 'REPLACED_BY_HIGHER_PRIORITY', reason_ref_id = %s WHERE detail_id = %s - """, (det_id, old_id)) + """, (detail_id, old_id)) cnx.commit() @@ -97,7 +101,7 @@ def resolve_priority( # Même priorité → rejet - return 0, "EQUAL_PRIORITY", det_id, None + return 0, "EQUAL_PRIORITY", detail_id, None # ------------------------------------------------- # Regle interval diff --git a/engine/info.txt b/engine/info.txt index 41d8019..b9b465f 100644 --- a/engine/info.txt +++ b/engine/info.txt @@ -3,7 +3,7 @@ attention sur le serveur mysql le % devrais enlever -config +config TABLE reader_config_detail — RÈGLES GÉNÉRALES --------------------------------------------- @@ -37,3 +37,20 @@ TABLE reader_config_detail — RÈGLES GÉNÉRALES 7) Source unique - Toutes les informations de configuration (TP et course) doivent provenir de reader_config_detail. - Aucune autre source de règle ne doit être utilisée dans le moteur. + + + Notes pour correction du moteur Python + +Les priorités ne fonctionnent pas. +voir si les priorité devrais etre a la fin +La logique actuelle doit être revue. + + + valider les multiple interval + + + +Concept général à corriger : + si ca plente pendant la validatione des regles + + valider premier tours