yaz/commit

allow empty category in stats

authorMichiel Hildebrand
Fri Mar 23 16:51:43 2012 +0100
committerMichiel Hildebrand
Fri Mar 23 16:51:43 2012 +0100
commitb4693b58f8be933665cf9c4a9fa9662d23a39edd
tree6ef525d4e2147f18edde5125b1f0fe0a9cb11fb0
parent558989a486c395bfaa3032b080c9570aa81305dc
Diff style: patch stat
diff --git a/applications/yaz_video_stats.pl b/applications/yaz_video_stats.pl
index cb6c0d5..22c8dcc 100644
--- a/applications/yaz_video_stats.pl
+++ b/applications/yaz_video_stats.pl
@@ -1,7 +1,7 @@
 :- module(yaz_video_stats,
 	  [ http_yaz_video_stats/1,
 	    flush_stats_cache/0
-  	  ]).
+	  ]).
 
 :- use_module(library(http/http_dispatch)).
 :- use_module(library(http/http_parameters)).
@@ -36,7 +36,7 @@ http_yaz_video_stats(Request) :-
 			[ user(User,
 				[optional(true),
 				 description('Current user id')]),
- 			  offset(Offset,
+			  offset(Offset,
 				[default(0), integer,
 				 description('Offset of the result list')]),
 			  limit(Limit,
@@ -45,13 +45,13 @@ http_yaz_video_stats(Request) :-
 			  sort(SortBy,
 			       [default(tags),
 				description('property to sort by')])
- 			]),
+			]),
 	video_stats(User, Stats0),
 	length(Stats0, NumberOfResults),
 	sort_stats(Stats0, SortBy, Stats1),
 	list_offset(Stats1, Offset, Stats2),
 	list_limit(Stats2, Limit, Stats, _),
-  	html_page(Stats, NumberOfResults, Offset, Limit).
+	html_page(Stats, NumberOfResults, Offset, Limit).
 
 sort_stats(Stats, SortBy, Sorted) :-
 	stats_arg(SortBy, Arg),
@@ -105,8 +105,10 @@ video_data(Video, Stats) :-
 	->  Title = Video
 	;   Title = Text
 	),
-  	rdf(Video, pprime:category, Cat0),
-	display_label(Cat0, Cat),
+	(   rdf(Video, pprime:category, Cat0)
+	->  display_label(Cat0, Cat)
+	;   Cat = ''
+	),
 	findall(P-U, video_process(Video, P, U), Pairs),
 	pairs_keys(Pairs, Games0),
 	pairs_values(Pairs, Users0),
@@ -125,12 +127,12 @@ video_data(Video, Stats) :-
 	length(Tags, UTs),
 	remove_no_scored(Es, Scored0),
 	pairs_keys(Scored0, ScoredTags),
- 	sort(ScoredTags, Scored),
+	sort(ScoredTags, Scored),
 	length(Scored0, Ms),
 	length(Scored, UMs).
 
 video_process(Video, Process, User) :-
-  	rdf(Process, opmv:used, Video),
+	rdf(Process, opmv:used, Video),
 	rdf(Process, rdf:type, pprime:'Game'),
 	rdf_has(Process, opmv:wasControlledBy, User).
 
@@ -149,7 +151,7 @@ remove_no_scored([E|Es], L) :-
 %	Emit HTML page with a list of Videos.
 
 html_page(Data, NumberOfResults, Offset, Limit) :-
- 	reply_html_page(yaz,
+	reply_html_page(yaz,
 			[ title(['YAZ - sessions'])
 			],
 			[ div(class(topic),
@@ -157,7 +159,7 @@ html_page(Data, NumberOfResults, Offset, Limit) :-
 				    h2(\video_count(NumberOfResults))),
 				div(class(body),
 				    div(id(stats), []))
- 			      ]),
+			      ]),
 			  div(class(footer),
 					div(class(paginator),
 					    \html_paginator(NumberOfResults, Offset, Limit)
@@ -176,8 +178,8 @@ html_page_yui(Stats) -->
 	{ data_columns(Columns),
 	  http_location_by_id(http_yaz_player, Link),
 	  prolog_to_json(Stats, JSONStats)
-  	},
-  	js_yui3([],
+	},
+	js_yui3([],
 		[node,event,datatable,'datatable-sort'],
 		[ \js_function_decl(playerLink, [o],
 				    \['return "<a href=\'',Link,'?video="+
@@ -190,7 +192,7 @@ html_page_yui(Stats) -->
 					     })),
 		  \js_call('statsTable.render'('#stats'))
 
-  		]).
+		]).
 
 :- json_object
 	stats(video:atom, title:atom, category:atom, games:integer,