virgil/commit
Add /aers/api/reaction/total to get total number of co-occurrences with a reaction
author | Michiel Hildebrand |
---|---|
Fri Jul 12 15:23:22 2013 +0200 | |
committer | Michiel Hildebrand |
Fri Jul 12 15:23:22 2013 +0200 | |
commit | 867a729d78cbba86372a0404ce9ed7ada94f1bf7 |
tree | bfbb60e767bbdae6740d6acc1741f2dc506b9bcd |
parent | 820b9c1aa9711942d04aab2195d8d43468d9b39f |
Diff style: patch stat
diff --git a/api/reactions.pl b/api/reactions.pl index 917fe80..e121241 100644 --- a/api/reactions.pl +++ b/api/reactions.pl @@ -9,6 +9,7 @@ :- http_handler(cliopatria(aers/api/reactions), http_reactions, []). :- http_handler(cliopatria(aers/api/reaction/count), http_reaction_count, []). +:- http_handler(cliopatria(aers/api/reaction/total), http_total_reaction_count, []). %% http_reactions(+Request) @@ -56,3 +57,17 @@ http_reaction_count(Request) :- reply_json(json([drugs=Drugs, reactions=Reactions, reaction_count=Count])). + + +%% http_total_reaction_count(+Request) + +http_total_reaction_count(Request) :- + http_parameters(Request, + [reaction(Reaction, + [ + ]) + ]), + setof(R-Drug, report(Drug, Reaction, [], R), Rs), + length(Rs, Count), + reply_json(json([reaction=Reaction, + reaction_count=Count])).