% Renvoie les id des enfants d'un message M (les messages qui répondent à M)\r
% ordrés du plus petit au plus grand.\r
% @spec enfants_id(integer()) -> [integer()]\r
-enfants_id(M) ->\r
+enfants_id(M_id) ->\r
+% resultat_transaction(mnesia:transaction(fun() ->\r
+% e(\r
+% qlc:sort(\r
+% q([E#reponse_minichat.repondant || E <- mnesia:table(reponse_minichat), E#reponse_minichat.cible =:= M]),\r
+% [{order, ascending}]\r
+% ),\r
+% [{tmpdir, ?KEY_SORT_TEMP_DIR}]\r
+% )\r
+% end)).\r
resultat_transaction(mnesia:transaction(fun() ->\r
- e(\r
- qlc:sort(\r
- q([E#reponse_minichat.repondant || E <- mnesia:table(reponse_minichat), E#reponse_minichat.cible =:= M]),\r
- [{order, ascending}]\r
- ),\r
- [{tmpdir, ?KEY_SORT_TEMP_DIR}]\r
- )\r
+ case mnesia:index_read(reponse_minichat, M_id, #reponse_minichat.cible) of\r
+ Enfants when is_list(Enfants) ->\r
+ lists:sort(lists:map(\r
+ fun(#reponse_minichat{repondant = Repondant}) -> Repondant end,\r
+ Enfants\r
+ ));\r
+ _ -> [] \r
+ end\r
end)).\r
\r
\r
a_repondu_a_message(Id_user, Id_mess) ->\r
resultat_transaction(mnesia:transaction(\r
fun() ->\r
- case mnesia:match_object({reponse_minichat, '_', Id_mess}) of\r
+ case mnesia:index_read(reponse_minichat, Id_mess, #reponse_minichat.cible) of\r
[] -> false;\r
Reponses ->\r
lists:any(\r