Skip to content

Consolidation d'un RC-RI à réception d'un RS-SR#386

Merged
bou3108 merged 10 commits intoconverter/rc-ri-single-messagefrom
feat/converter/generate-rc-ri-from-rs-sr
Mar 30, 2026
Merged

Consolidation d'un RC-RI à réception d'un RS-SR#386
bou3108 merged 10 commits intoconverter/rc-ri-single-messagefrom
feat/converter/generate-rc-ri-from-rs-sr

Conversation

@bou3108
Copy link
Copy Markdown
Collaborator

@bou3108 bou3108 commented Mar 24, 2026

🔎 Détails

Dans le converter, à la réception d’un RS-SR, si toutes les ressources ont un statut, créer le message RC-RI et le retourner pour transmission aux pompiers.

  • Ajout d'un helper mergeInfoAndResources, qui génère un RC-RI à partir d'un RS-RI et d'une liste de RS-SR
  • Règle de gestion : RC-RI si et seulement si toutes les ressources référencées dans le RS-RI ont un RS-SR associé dans la liste, None sinon
  • Ajout de tests sur cett méthode

📄 Documentation

Ajoutez un (des) lien(s) vers la documentation si nécessaire

📸 Captures d'écran

Avant Après

🔗 Ticket associé

Asana

@bou3108 bou3108 changed the base branch from main to converter/rc-ri-single-message March 24, 2026 08:21
@github-actions
Copy link
Copy Markdown

There is no coverage information present for the Files changed

Total Project Coverage 52.5% 🍏

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

Coverage

Converter - python code coverage
FileStmtsMissCoverMissing
constants.py40100% 
conversion_mixin.py23195%24
converter.py67395%26, 94–95
database.py322231%12, 16, 18–21, 23, 25, 27, 29–38, 40–41, 49
logging_config.py35294%29, 36
utils.py164398%57, 108, 120
cisu
   base_cisu_converter.py33390%7, 25, 31
   constants.py40100% 
   identical_cisu_converter.py90100% 
   utils.py150100% 
cisu/create_case
   create_case_cisu_constants.py310100% 
   create_case_cisu_converter.py145199%112
cisu/reference
   reference_converter.py9277%9, 13
cisu/resources_info
   resources_info_cisu_constants.py110100% 
   resources_info_cisu_converter.py146199%154
   resources_info_cisu_helper.py150100% 
cisu/resources_status
   resources_status_constants.py30100% 
   resources_status_converter.py30196%31
conversion_strategy
   cisu_conversion_strategy.py49295%68, 93
   conversion_strategy.py70100% 
   health_conversion_strategy.py460100% 
models
   persisted_message.py130100% 
repositories
   message_repository.py701282%90–91, 98, 118–120, 122–123, 125, 171–173
versions
   base_message_converter.py831285%13, 72–74, 86, 98, 102, 106, 110, 114, 118, 124
   error_converter.py5180%7
   identical_message_converter.py150100% 
   utils.py26580%34–37, 43
versions/create_case_health
   constants.py40100% 
   create_case_health_converter.py1780100% 
   create_case_health_update_converter.py50100% 
versions/create_case_health/v1_v2
   constants.py170100% 
   utils.py460100% 
versions/create_case_health/v2_v3
   constants.py290100% 
versions/geo_positions_update
   geo_positions_update_constants.py40100% 
   geo_positions_update_converter.py49393%31, 42, 79
versions/geo_resources_details
   geo_resources_details_constants.py40100% 
   geo_resources_details_converter.py270100% 
versions/reference
   reference_constants.py20100% 
   reference_converter.py130100% 
versions/resources_engagement
   resources_engagement_constants.py30100% 
   resources_engagement_converter.py220100% 
versions/resources_info
   resources_info_constants.py200100% 
   resources_info_converter.py870100% 
versions/resources_request
   resources_request_constants.py20100% 
   resources_request_converter.py210100% 
versions/resources_response
   resources_response_constants.py40100% 
   resources_response_converter.py160100% 
versions/resources_status
   resources_status_constants.py100100% 
   resources_status_converter.py390100% 
TOTAL16927495% 

@bou3108 bou3108 force-pushed the feat/converter/generate-rc-ri-from-rs-sr branch from d74e45b to 51a60ca Compare March 24, 2026 13:51
@github-actions
Copy link
Copy Markdown

There is no coverage information present for the Files changed

Total Project Coverage 52.4% 🍏

@bou3108 bou3108 force-pushed the feat/converter/generate-rc-ri-from-rs-sr branch from 51a60ca to 127ff73 Compare March 24, 2026 13:55
@github-actions
Copy link
Copy Markdown

There is no coverage information present for the Files changed

Total Project Coverage 52.4% 🍏

@github-actions
Copy link
Copy Markdown

There is no coverage information present for the Files changed

Total Project Coverage 52.4% 🍏

@bou3108 bou3108 marked this pull request as ready for review March 24, 2026 14:15
"""

try:
resources = rs_ri["content"]["jsonContent"]["embeddedJsonContent"]["message"][
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utiliser get_field_value et une constante pour le path

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comme on manipule directement une resource désormais, ça m'a paru moins nécessaire


for rs_sr in rs_sr_list:
try:
resource_status = rs_sr["content"]["jsonContent"]["embeddedJsonContent"][
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem

return None

# state is an array in RS-RI
resource["state"] = [resource_state_by_id[resource_id]]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utiliser un set_value ici

return "resourcesInfoCisu"

@classmethod
def from_rs_to_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any] | None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changer le type pour retourner une liste de Dict[str, Any] au lieu de None

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai renvoyé {} car dans le cas passant cette méthode renvoie un RC-RI, et c'est à plus haut nivau que c'est empaqueté dans un array


rs_ri = get_last_rs_ri_by_case_id(case_id)
if rs_ri is None: # No RS-RI persisted yet, we do nothing
return None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retourner plutôt une liste vide (None n'est pas gérer par la méthode appelante)

@github-actions
Copy link
Copy Markdown

There is no coverage information present for the Files changed

Total Project Coverage 52.4% 🍏

@github-actions
Copy link
Copy Markdown

There is no coverage information present for the Files changed

Total Project Coverage 52.4% 🍏

result = []

for rs_sr in rs_sr_list:
resource_status = get_field_value(rs_sr, "$.resourceStatus")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce n'est pas $.state.status d'après le schéma du RS-SR ? Et mettre le chemin d'accès dans une constante.


persisted_rs_ri = get_last_rs_ri_by_case_id(case_id)
if persisted_rs_ri is None: # No RS-RI persisted yet, we return an empty object
return {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plutôt liste vide du coup ? Sinon on va renvoyer un objet vide au dispatcher. Aussi tu peux ajouter un commentaire TODO pour prévoir de renvoyer une erreur à la place ? C'est dans les tâches suivantes de gestion des cas à la marge.

@classmethod
def from_rs_to_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any]:
content = cls.copy_rs_input_use_case_content(edxl_json)
case_id = get_field_value(content, "$.caseId")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce serait top de mettre le chemin dans une constante.

merged_rs_ri = merge_info_and_resources(resources, resources_status_list)

if merged_rs_ri is None:
return {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas besoin de traiter ce cas ici, si il manque une ressource, from_rs_to_cisu va déjà retourner une erreur.

def merge_info_and_resources(
resources: list[dict],
resources_status_list: list[dict],
) -> list[dict] | None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense qu'on devrait forcement au moins retourner le rs-ri de base sans modification. Ce n'est pas responsabilité de cette fonction de gérer le cas d'une ressource sans status. C'est géré ensuite dans la méthode de conversion appelée.

rs_sr_state = None

# resource has no state and no RS-SR has been emitted yet
if "state" not in resource and rs_sr_state is None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On peut ainsi enlever ce cas

if merged_rs_ri is None:
return {}

set_value(rs_ri, "path", merged_rs_ri)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attention au path qui n'est pas le bon ici

@github-actions
Copy link
Copy Markdown

There is no coverage information present for the Files changed

Total Project Coverage 52.4% 🍏

@bou3108 bou3108 force-pushed the feat/converter/generate-rc-ri-from-rs-sr branch from 1d92ac5 to 8bf65e6 Compare March 27, 2026 12:29
@github-actions
Copy link
Copy Markdown

There is no coverage information present for the Files changed

Total Project Coverage 52.4% 🍏

@github-actions
Copy link
Copy Markdown

There is no coverage information present for the Files changed

Total Project Coverage 52.4% 🍏

@github-actions
Copy link
Copy Markdown

There is no coverage information present for the Files changed

Total Project Coverage 52.4% 🍏

@bou3108 bou3108 merged commit 942288b into converter/rc-ri-single-message Mar 30, 2026
2 checks passed
@bou3108 bou3108 deleted the feat/converter/generate-rc-ri-from-rs-sr branch March 30, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants