annotation_dashboard/commit

make sure representative work hash an image available ...

authorJacco van Ossenbruggen
Sun Sep 21 15:54:29 2014 +0200
committerJacco van Ossenbruggen
Sun Sep 21 15:54:29 2014 +0200
commitcd9f4820f907de4001ffbccb06411694f4203a87
tree6ee139447c16aa58aab02f17338ba9d980444d0c
parent41949a69c91a5df29969c370a6884a902540053b
Diff style: patch stat
diff --git a/lib/dashboard_util.pl b/lib/dashboard_util.pl
index 7af995f..0401519 100644
--- a/lib/dashboard_util.pl
+++ b/lib/dashboard_util.pl
@@ -13,12 +13,18 @@
 	    find_workers/1
 	  ]).
 
+:- use_module(library(apply)).
+:- use_module(library(lists)).
+:- use_module(library(option)).
+:- use_module(library(pairs)).
+
 :- use_module(library(semweb/rdf_db)).
 :- use_module(library(semweb/rdfs)).
 :- use_module(library(semweb/rdf_label)).
 :- use_module(library(count)).
 
 :- use_module(library(oa_annotation)).
+:- use_module(applications(annotation)).
 
 :- rdf_meta
 	task_property_blacklist(t).
@@ -34,12 +40,8 @@ blacklisted_annotation(A) :-
 	;
 	rdf_has(A, oa:annotedBy, 'http://localhost:3020/user/admin')
 	;
-	has_no_image(A)
-	;
 	rdf_has(A, dcterms:title, literal(test)).
 
-has_no_image(_A) :- fail.
-
 is_tag(A) :-
 	rdf_has(A, oa:motivatedBy, oa:tagging).
 
@@ -148,10 +150,17 @@ count_annotations(Target, Count-Target) :-
 representative(Candidates, Representative) :-
 	maplist(count_annotations, Candidates, Counts),
 	sort(Counts, Sorted),
-	reverse(Sorted, [_Count-Representative|_]),!.
-
+	pairs_values(Sorted, Values),
+	reverse(Values, Ordered),
+	find_first_with_image(Ordered, Representative).
 representative(_, no_representative_found).
 
+find_first_with_image([H|_], H) :-
+	\+ no_object_image(H), !.
+find_first_with_image([_|T], First) :-
+	find_first_with_image(T, First).
+
+
 property_key_label(500, targets_untouched, 'works without tags').
 property_key_label(200, targets_total,     'works targeted').
 property_key_label(250, targets_complete,  'works completed').