- outputs/platform, outputs/prospect : scripts de construction des decks commerciaux + captures sources et .pptx generes. - outputs/mnaha : seed complet de l'instance de demo luxembourgeoise (scripts par etape, contenus, images generees), le deck en version marque blanche et en version brandee, le PDF de presentation. - outputs/Wireframes : maquettes app mobile, app web et manager. - interview clients : notes de l'entretien Fourneau St Michel. state.json et les __pycache__ sont ignores : le premier porte les cles d'API de l'instance seedee, les scripts le regenerent.
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Étape 9 — dédoublonnage des liens de configuration.
|
|
|
|
`PUT /api/ApplicationInstance` fait `Configurations = dto.configurations` : une
|
|
collection détachée réaffectée à une entité suivie, qu'EF insère comme neuve.
|
|
Toute mise à jour d'application qui renvoie ses liens les duplique donc.
|
|
|
|
On garde, par couple (application, configuration), le lien porteur d'un
|
|
appareil, sinon le plus ancien.
|
|
"""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from api import Api
|
|
|
|
STATE = Path(__file__).resolve().parent / "state.json"
|
|
|
|
|
|
def main():
|
|
api = Api()
|
|
state = json.loads(STATE.read_text(encoding="utf-8"))
|
|
|
|
for name, app_id in state["apps"].items():
|
|
links = api.get(f"/api/ApplicationInstance/{app_id}/application-link") or []
|
|
|
|
by_config = {}
|
|
for link in links:
|
|
by_config.setdefault(link["configurationId"], []).append(link)
|
|
|
|
for config_id, group in by_config.items():
|
|
if len(group) == 1:
|
|
continue
|
|
group.sort(key=lambda l: (l.get("deviceId") is None,
|
|
l.get("dateCreation") or ""))
|
|
keep, extra = group[0], group[1:]
|
|
for link in extra:
|
|
api.delete(f"/api/ApplicationInstance/{app_id}"
|
|
f"/application-link/{link['id']}")
|
|
print(f" {name} / {config_id[:8]} : {len(extra)} doublon(s) supprimé(s), "
|
|
f"gardé {keep['id'][:8]}"
|
|
f"{' (avec appareil)' if keep.get('deviceId') else ''}")
|
|
|
|
remaining = api.get(f"/api/ApplicationInstance/{app_id}/application-link") or []
|
|
print(f" {name} : {len(remaining)} liens")
|
|
|
|
print("\nétape 9 terminée")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|