accurator/commit

Simplified the population of earlier set expert values in expertise screen, fixes #18

authorChris Dijkshoorn
Mon Mar 9 16:43:04 2015 +0000
committerChris Dijkshoorn
Mon Mar 9 16:43:04 2015 +0000
commit4325e828757289a586555d8fb160c0754c6a7923
tree6944840ed7034ecabbed6e6a27054bf45fa01c31
parent09a3415a6c4db967281f30b61d7f426de8e14c87
Diff style: patch stat
diff --git a/api/accurator.pl b/api/accurator.pl
index 825c6c6..eac4a9d 100644
--- a/api/accurator.pl
+++ b/api/accurator.pl
@@ -152,12 +152,9 @@ get_parameters_expertise(Request, Options) :-
 expertise_values_api(Request) :-
 	member(method(get), Request),
 	logged_on(User),
-	setof(Topic, User^Expertise^
-		   (   rdf(Expertise, hoonoh:from, User),
-			   rdf(Expertise, hoonoh:toTopic, Topic)),
-		   Topics),
-	maplist(get_user_expertise(User), Topics, TopicDictPairs),
-	dict_pairs(ExpertiseDict, elements, TopicDictPairs),
+	get_domain(User, Domain),
+	get_user_expertise_domain(User, Domain, ExpertiseValues),
+	dict_pairs(ExpertiseDict, elements, ExpertiseValues),
 	reply_json_dict(ExpertiseDict).
 
 expertise_values_api(Request) :-
diff --git a/lib/accurator/expertise.pl b/lib/accurator/expertise.pl
index 4f67350..e0a70cc 100644
--- a/lib/accurator/expertise.pl
+++ b/lib/accurator/expertise.pl
@@ -2,7 +2,7 @@
 					  get_domain_topics/2,
 					  assert_expertise_relationship/2,
 					  get_user_expertise/3,
-					  get_user_expertise_domain/2,
+					  get_user_expertise_domain/3,
 					  get_latest_user_expertise/3]).
 
 /** <module> Expertise
@@ -202,9 +202,7 @@ get_label(_Locale, Uri, Label) :-
 %%	get_user_expertise_domain(-ExpertiseValues, +Options)
 %
 %	Retrieves a list of expertise values based on user and domain.
-get_user_expertise_domain(ExpertiseValues, Options) :-
-	option(user(User), Options),
-	option(domain(Domain), Options),
+get_user_expertise_domain(User, Domain, ExpertiseValues) :-
 	get_domain_topics(Domain, Topics),
 	maplist(get_latest_user_expertise(User), Topics, ExpertiseValues).
 
diff --git a/web/js/accurator_expertise.js b/web/js/accurator_expertise.js
index 07e93e0..612a9ae 100644
--- a/web/js/accurator_expertise.js
+++ b/web/js/accurator_expertise.js
@@ -153,27 +153,14 @@ function setSliderValues() {
 	$.getJSON("expertise_values")
 	.done(function(expertValues){
 		var uris = Object.keys(expertValues);
-
 		for(i=0; i<uris.length; i++){
 			// Generate id based on uri
 			var uri = uris[i];
 			var id = generateIdFromUri(uri);
-			
-			// Check if element exists on page
-			if(!($("#"+id) === [])) {
-				var valueList = expertValues[uri];
-				
-				// Sort the value list on date
-				valueList.sort(function(a,b){
-					return new Date(b.date) - new Date(a.date);
-				});
-				
-				// Get the most recent value and scale back
-				var value = Number(valueList[0].value);
-				var descaledValue = (value * 4) + 1;
-				// Set corresponding slider
-				$("#"+id).slider('setValue', descaledValue);
-			}
+			var value = Number(expertValues[uris[i]]);
+			var descaledValue = (value * 4) + 1;
+			// Set slider value
+			$("#"+id).slider('setValue', descaledValue);
 		}
 	});
 }