Skip to content

Commit

Permalink
issues #SB_29,SB_32 feat:adding new feature for profile completeness
Browse files Browse the repository at this point in the history
  • Loading branch information
manzarul.haque committed Sep 25, 2017
1 parent 991ecfa commit 020f610
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.sunbird.common.models.util.datasecurity.OneWayHashing;
import org.sunbird.common.models.util.datasecurity.impl.DefaultEncryptionServivceImpl;
import org.sunbird.common.responsecode.ResponseCode;
import org.sunbird.common.services.ProfileCompletenessService;
import org.sunbird.common.services.impl.ProfileCompletenessFactory;
import org.sunbird.helper.ServiceFactory;
import org.sunbird.learner.util.CourseBatchSchedulerUtil;
import org.sunbird.learner.util.Util;
Expand Down Expand Up @@ -754,6 +756,10 @@ private boolean updateCourseManagement(Map<String, Object> data) {
private boolean insertDataToElastic(String index, String type, String identifier,
Map<String, Object> data) {
ProjectLogger.log("making call to ES for type ,identifier ,data==" + type +" " + identifier + data);
//now calculate profile completeness and error filed and store it in ES
ProfileCompletenessService service = ProfileCompletenessFactory.getInstance();
Map<String,Object> responsemap = service.computeProfile(data);
data.putAll(responsemap);
String response = ElasticSearchUtil.createData(index, type, identifier, data);
ProjectLogger.log("Getting ES save response for type , identiofier==" +type+" " + identifier + " "+ response);
if (!ProjectUtil.isStringNullOREmpty(response)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,23 @@ private void getUserDetailsByLoginId(Request actorMessage) {
//remove email and phone no from response
result.remove(JsonKey.EMAIL);
result.remove(JsonKey.PHONE);
if(null != actorMessage.getRequest().get(JsonKey.FIELDS)){
List<String> requestFields = (List)actorMessage.getRequest().get(JsonKey.FIELDS);
if (requestFields != null){
if(!requestFields.contains(JsonKey.COMPLETENESS)){
result.remove(JsonKey.COMPLETENESS);
}
if(!requestFields.contains(JsonKey.MISSING_FIELDS)){
result.remove(JsonKey.MISSING_FIELDS);
}
} else {
result.remove(JsonKey.MISSING_FIELDS);
result.remove(JsonKey.COMPLETENESS);
}
}else {
result.remove(JsonKey.MISSING_FIELDS);
result.remove(JsonKey.COMPLETENESS);
}
response.put(JsonKey.RESPONSE, result);
} else {
result = new HashMap<>();
Expand Down Expand Up @@ -274,17 +291,17 @@ private void getUserProfile(Request actorMessage) {
if(null != actorMessage.getRequest().get(JsonKey.FIELDS)){
String requestFields = (String)actorMessage.getRequest().get(JsonKey.FIELDS);
if(!ProjectUtil.isStringNullOREmpty(requestFields)){
if(requestFields.contains(JsonKey.COMPLETENESS)){
result.put(JsonKey.COMPLETENESS, 70);
if(!requestFields.contains(JsonKey.COMPLETENESS)){
result.remove(JsonKey.COMPLETENESS);
}
if(requestFields.contains(JsonKey.MISSING_FIELDS)){
List<String> missingFields = new ArrayList<>();
missingFields.add("skills");
missingFields.add("education");
result.put(JsonKey.MISSING_FIELDS, missingFields);
if(!requestFields.contains(JsonKey.MISSING_FIELDS)){
result.remove(JsonKey.MISSING_FIELDS);
}
}

}else {
result.remove(JsonKey.MISSING_FIELDS);
result.remove(JsonKey.COMPLETENESS);
}
Response response = new Response();
if (null != result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.sunbird.common.models.util.datasecurity.DecryptionService;
import org.sunbird.common.request.Request;
import org.sunbird.common.responsecode.ResponseCode;
import org.sunbird.common.services.ProfileCompletenessService;
import org.sunbird.common.services.impl.ProfileCompletenessFactory;
import org.sunbird.helper.ServiceFactory;
import org.sunbird.learner.actors.BackgroundJobManager;
import org.sunbird.learner.util.Util;
Expand Down Expand Up @@ -200,6 +202,10 @@ private Map<String, Object> getUserDetails(Entry<String, Object> entry) {
email = decService.decryptData(email);
userMap.put(JsonKey.MASKED_EMAIL, maskingService.maskEmail(email));
}
//compute profile completeness and error field.
ProfileCompletenessService service = ProfileCompletenessFactory.getInstance();
Map<String,Object> profileResponse = service.computeProfile(userMap);
userMap.putAll(profileResponse);
ProjectLogger.log("fetching user data completed");
return userMap;
}
Expand Down

0 comments on commit 020f610

Please sign in to comment.