X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=modules%2Ferl%2Feuphorik_bd.erl;h=0bda09f7fe2d7a7bbe6f758201e19136a611cd7f;hp=dff71dbf1fb68aef172c68509d213ac6b3c83c21;hb=c4d03b8678ab3ce2442d81730ba96dd26768274a;hpb=654e586482addf692991118ab9a4c5ead082457e 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(