resultat_transaction(mnesia:transaction(fun() ->
C = cursor(
qlc:keysort(
- 9,
+ #user.date_derniere_connexion,
q([E || E <- mnesia:table(user)]),
[{order, descending}]
),
F = fun() ->
C = cursor(
qlc:keysort(
- 2,
+ #minichat.id,
q([E#minichat{contenu = contenu_message(E)} || E <- mnesia:table(minichat)]),
[{order, descending}]
),
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}])
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
)).
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
)).
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
-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]).