Source: site.view [edit]
Function name: cmdAddPerson
Arguments: person,optimize
Description: Adds a person's resume info to resume database
Page type: webl
Render function:  
Module: skillsrank

Page source:

var reader = Wub_ReadLuceneIndex("resumes") ? nil;

var docs = [];
var ok = true;

if reader != nil then
   docs = Wub_LuceneSearch(reader, "id", person["id"], 1, "standard");
   ok = Wub_CloseLuceneIndex(reader);
else 
   var writer = Wub_NewLuceneIndex("resumes", true, "standard");
   ok = Wub_CloseLuceneIndex(writer);
end;

if (ok and (docs.size() == 0)) then

   var writer = Wub_NewLuceneIndex("resumes", false, "standard");

   var doc = Wub_NewLuceneDocument();

// Fields from LinkedIn
   ok = ok and Wub_AddLuceneField(doc, "id", person["id"], true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "last-name", (person["last-name"] ? ""), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "first-name", (person["first-name"] ? ""), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "name", ((person["first-name"] + " " + person["last-name"]) ? ""), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "location", (person["location"] ? ""), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "headline", (person["headline"] ? "No headline"), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "industry", (person["industry"]?"Unknown Industry"), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "picture-url", (person["picture-url"]? ""), true, false, 0);
   ok = ok and Wub_AddLuceneField(doc, "site-standard-profile-request", 
                                       (person["site-standard-profile-request"]?""), true, false, 0);
   ok = ok and Wub_AddLuceneField(doc, "positions", (ToString(person["positions"])?"No positions"), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "educations", (ToString(person["educations"])?"No positions"), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "summary", (person["summary"]?""), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "site-standard-profile-request", 
                        (ToString(person["site-standard-profile-request"])?"No profile"), true, false, 0);

// Special metadata we add
   ok = ok and Wub_AddLuceneField(doc, "region", (ToString(person["region"])?""), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "salary", (ToString(person["salary"])?""), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "eduScore", (ToString(person["eduScore"])?""), true, false, 0);
   ok = ok and Wub_AddLuceneField(doc, "degreeScore", (ToString(person["degreeScore"])?""), true, false, 0);
   ok = ok and Wub_AddLuceneField(doc, "schoolScore", (ToString(person["schoolScore"])?""), true, false, 0);
   ok = ok and Wub_AddLuceneField(doc, "qSchoolScore", (ToString(person["qSchoolScore"])?""), true, true, 0);
   ok = ok and Wub_AddLuceneField(doc, "qEduScore", (ToString(person["qEduScore"])?""), true, true, 0);

   var skills = (person["headline"] ? "") + " " +
      ((person["first-name"] + " " + person["last-name"]) ? "") + " " +
      (person["headline"] ? "") + " " +
      (person["industry"] ? "") + " " +
      (person["location"] ? "") + " " +
      (person["headline"] ? "") + " " +
      (ToString(person["positions"]) ? "") + " " +
      (ToString(person["qEduScore"])?"") + " " +
      (ToString(person["educations"]) ? "");


   ok = ok and Wub_AddLuceneField(doc, "skills", skills, true, true, 0);

   ok = ok and Wub_AddLuceneDocument(writer, doc);

   if optimize == true then
      ok = ok and Wub_OptimizeLucene(writer);
   end;

   ok = ok and Wub_CloseLuceneIndex(writer);
else  // person already in database
   ok = false
end;

ok;