From 016c2536b3d43dee91de0d13b597ad5525dc9214 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Mon, 2 Jun 2008 20:20:52 +0000 Subject: [PATCH] =?utf8?q?MOD=20remplacement=20des=20num=C3=A9ros=20des=20?= =?utf8?q?champs=20en=20dure=20par=20leur=20num=C3=A9ro=20pas=20en=20dure?= =?utf8?q?=20!=20ouf=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- modules/erl/euphorik_bd.erl | 13 ++++++------- modules/erl/euphorik_minichat_conversation.erl | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/erl/euphorik_bd.erl b/modules/erl/euphorik_bd.erl index 93cb835..6eaea54 100755 --- a/modules/erl/euphorik_bd.erl +++ b/modules/erl/euphorik_bd.erl @@ -308,7 +308,7 @@ print_users(N) -> resultat_transaction(mnesia:transaction(fun() -> C = cursor( qlc:keysort( - 9, + #user.date_derniere_connexion, q([E || E <- mnesia:table(user)]), [{order, descending}] ), @@ -516,7 +516,7 @@ messages(N, P) -> F = fun() -> C = cursor( qlc:keysort( - 2, + #minichat.id, q([E#minichat{contenu = contenu_message(E)} || E <- mnesia:table(minichat)]), [{order, descending}] ), @@ -568,7 +568,7 @@ messages_by_ids(Ids) -> fun() -> % TODO : optimisations ? serait-ce du O(n) ? e(qlc:keysort( - 2, + #minichat.id, q([E || E <- mnesia:table(minichat), lists:any(fun(Id) -> Id =:= E#minichat.id end, Ids)]), [{order, ascending}] ),[{tmpdir, ?KEY_SORT_TEMP_DIR}]) @@ -753,7 +753,7 @@ can_register(IP) -> trolls() -> resultat_transaction(mnesia:transaction( fun() -> - e(qlc:keysort(2, q([T || T <- mnesia:table(troll)])), [{tmpdir, ?KEY_SORT_TEMP_DIR}]) + e(qlc:keysort(#troll.id, q([T || T <- mnesia:table(troll)])), [{tmpdir, ?KEY_SORT_TEMP_DIR}]) end )). @@ -762,7 +762,7 @@ trolls() -> trolls(Last_id) -> resultat_transaction(mnesia:transaction( fun() -> - e(qlc:keysort(2, q([T || T <- mnesia:table(troll), T#troll.id > Last_id, T#troll.date_post =:= undefined])), [{tmpdir, ?KEY_SORT_TEMP_DIR}]) + e(qlc:keysort(#troll.id, q([T || T <- mnesia:table(troll), T#troll.id > Last_id, T#troll.date_post =:= undefined])), [{tmpdir, ?KEY_SORT_TEMP_DIR}]) end )). @@ -852,8 +852,7 @@ troll_by_id(Troll_id) -> current_troll() -> resultat_transaction(mnesia:transaction( fun() -> - % TODO : ya pas moyen de désigner le champs plutot qu'avec un nombre pour le tri ? - C = cursor(qlc:keysort(5, q([T || T <- mnesia:table(troll), T#troll.date_post =/= undefined]), [{order, descending}]), [{tmpdir, ?KEY_SORT_TEMP_DIR}]), + C = cursor(qlc:keysort(#troll.date_post, q([T || T <- mnesia:table(troll), T#troll.date_post =/= undefined]), [{order, descending}]), [{tmpdir, ?KEY_SORT_TEMP_DIR}]), R = case qlc:next_answers(C, 1) of [T] -> T; _ -> aucun diff --git a/modules/erl/euphorik_minichat_conversation.erl b/modules/erl/euphorik_minichat_conversation.erl index 7f6082c..60f92e4 100755 --- a/modules/erl/euphorik_minichat_conversation.erl +++ b/modules/erl/euphorik_minichat_conversation.erl @@ -35,7 +35,7 @@ -include_lib("stdlib/include/qlc.hrl"). -import(lists, [reverse/1, any/2, map/2, sublist/3, filter/2]). -import(euphorik_bd, [resultat_transaction/1]). --import(qlc, [e/2, q/1, keysort/3]). +-import(qlc, [e/2, q/1]). -import(mnesia, [table/1, transaction/1]). -- 2.45.2