Skip to content

Commit

Permalink
Merge pull request #158 from khoa-nd/master
Browse files Browse the repository at this point in the history
Merged
  • Loading branch information
khoa-nd committed Feb 3, 2015
2 parents 271cf1a + 634525f commit 5556e6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ private void processUserEmail(UserImportData user) {
}

private void extractUserSkillSetFromDescription(UserImportData user) {
final String USER_DESCRIPTION_PATTERN = "([A-Za-z0-9-_]+)*\\shas\\s([0-9]+)*\\s(repositories|repository)\\swritten\\sin\\s"
+ "(([\\w\\s,\\+]+)*|([\\w\\s,\\+]+)*\\sand\\s([\\w\\+]+)*)\\.\\s"
+ "Follow\\stheir\\scode\\son\\sGitHub\\.";
Pattern pattern = Pattern.compile(USER_DESCRIPTION_PATTERN);
Matcher matcher = pattern.matcher(user.getDescription());
if (matcher.matches()) {
user.setNumberOfRepositories(Integer.valueOf(matcher.group(2)));
String skills = matcher.group(4).replaceAll("and", EmailValidator.COMMA);
user.setSkills(Arrays.asList(StringUtils.split(StringUtils.deleteWhitespace(skills), EmailValidator.COMMA)));
if (StringUtils.isNotEmpty(user.getDescription())) {
final String USER_DESCRIPTION_PATTERN = "([A-Za-z0-9-_]+)*\\shas\\s([0-9]+)*\\s(repositories|repository)\\swritten\\sin\\s"
+ "(([\\w\\s,\\+]+)*|([\\w\\s,\\+]+)*\\sand\\s([\\w\\+]+)*)\\.\\s"
+ "Follow\\stheir\\scode\\son\\sGitHub\\.";
Pattern pattern = Pattern.compile(USER_DESCRIPTION_PATTERN);
Matcher matcher = pattern.matcher(user.getDescription());
if (matcher.matches()) {
user.setNumberOfRepositories(Integer.valueOf(matcher.group(2)));
String skills = matcher.group(4).replaceAll("and", EmailValidator.COMMA);
user.setSkills(Arrays.asList(StringUtils.split(StringUtils.deleteWhitespace(skills), EmailValidator.COMMA)));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.techlooper.repository.userimport.UserImportRepository;
import com.techlooper.service.UserService;
import com.techlooper.service.VietnamWorksUserService;
import org.apache.commons.lang3.StringUtils;
import org.dozer.Mapper;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.index.query.FilterBuilders;
Expand Down Expand Up @@ -107,8 +108,11 @@ public int addCrawledUserAll(List<UserImportData> users) {
List<UserImportEntity> shouldBeSavedUsers = new ArrayList<>();

for (UserImportData user : users) {
UserImportEntity userImportEntity = findUserImportByEmail(user.getEmail());
if (StringUtils.isEmpty(user.getUsername())) {
continue;
}

UserImportEntity userImportEntity = findUserImportByEmail(user.getEmail());
if (userImportEntity != null) {
userImportEntity.withProfile(user.getCrawlerSource(), user);
} else {
Expand Down

0 comments on commit 5556e6e

Please sign in to comment.