R/suggestskill.R

Defines functions suggestskill

suggestskill <- function(id, skills, login, pass) {
  library(RMySQL)
  library(dplyr)
  
  
  con.ontology <- dbConnect(
    MySQL(),
    user = login,
    password = pass,
    dbname = "ontology",
    host = "185.19.28.182"
  )
  
  input <- gsub("“|”", "'", paste(dQuote(sub(" ","",unlist(strsplit(skills,split = ",")))),collapse = ", "))

  ont.query <- paste("SELECT tmaID from tbskills WHERE name in ( ", input, ")", sep = "")
  db.ont <- dbSendQuery(con.ontology, ont.query)
  current.skills <- dbFetch(db.ont, n = -1)
  
  dbClearResult(dbListResults(con.ontology)[[1]])
  dbDisconnect(con.ontology)
  
  
  con.vacarchive <- dbConnect(
    MySQL(),
    user = login,
    password = pass,
    dbname = "vac_archive",
    host = "185.19.28.182"
  )
  
  query.skill <-
    paste("SELECT * FROM good_job_skills WHERE ful_id = ",
          id,
          " ORDER BY rel_tfidf DESC",
          sep = "")
  
  db.job <- dbSendQuery(con.vacarchive, query.skill)
  job.skills <- dbFetch(db.job, n = -1)
  
  dbClearResult(dbListResults(con.vacarchive)[[1]])
  dbDisconnect(con.vacarchive)
  
  missing <-
    job.skills %>% filter(!tma_id %in% current.skills$tmaID)
  return(missing %>% select(tma_id))
}
MichalMiko6211/skillsuggestions documentation built on Sept. 12, 2017, 5:20 p.m.