From: Greg Burri Date: Sun, 27 Jul 2008 12:12:28 +0000 (+0000) Subject: FIX remplacement des match_object par des index_read X-Git-Tag: 1.1.0~37 X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=c4d03b8678ab3ce2442d81730ba96dd26768274a;p=euphorik.git FIX remplacement des match_object par des index_read --- diff --git a/modules/erl/euphorik_bd.erl b/modules/erl/euphorik_bd.erl index dff71db..0bda09f 100755 --- a/modules/erl/euphorik_bd.erl +++ b/modules/erl/euphorik_bd.erl @@ -475,15 +475,25 @@ parents_id(M_id) -> % Renvoie les id des enfants d'un message M (les messages qui répondent à M) % ordrés du plus petit au plus grand. % @spec enfants_id(integer()) -> [integer()] -enfants_id(M) -> +enfants_id(M_id) -> +% resultat_transaction(mnesia:transaction(fun() -> +% e( +% qlc:sort( +% q([E#reponse_minichat.repondant || E <- mnesia:table(reponse_minichat), E#reponse_minichat.cible =:= M]), +% [{order, ascending}] +% ), +% [{tmpdir, ?KEY_SORT_TEMP_DIR}] +% ) +% end)). resultat_transaction(mnesia:transaction(fun() -> - e( - qlc:sort( - q([E#reponse_minichat.repondant || E <- mnesia:table(reponse_minichat), E#reponse_minichat.cible =:= M]), - [{order, ascending}] - ), - [{tmpdir, ?KEY_SORT_TEMP_DIR}] - ) + case mnesia:index_read(reponse_minichat, M_id, #reponse_minichat.cible) of + Enfants when is_list(Enfants) -> + lists:sort(lists:map( + fun(#reponse_minichat{repondant = Repondant}) -> Repondant end, + Enfants + )); + _ -> [] + end end)). @@ -514,7 +524,7 @@ est_une_reponse_a_user(Id_user, Id_mess) -> a_repondu_a_message(Id_user, Id_mess) -> resultat_transaction(mnesia:transaction( fun() -> - case mnesia:match_object({reponse_minichat, '_', Id_mess}) of + case mnesia:index_read(reponse_minichat, Id_mess, #reponse_minichat.cible) of [] -> false; Reponses -> lists:any(