diff --git a/go.work.sum b/go.work.sum index e153131..046e2c8 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,4 +1,6 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= diff --git a/scraper/interest/interest.go b/scraper/interest/interest.go index 0a04d3c..34e3acd 100644 --- a/scraper/interest/interest.go +++ b/scraper/interest/interest.go @@ -8,18 +8,18 @@ import ( "sync" ) -func CheckIfInterested(description string) bool { - keywords := []string{"typescript", "node", "nodejs", "node.js", "go", "golang"} +func CheckIfInterested(description string) string { + keywords := []string{"go", "golang", "node", "nodejs", "node.js", "typescript"} // Check if keywords are present in the job's text descriptionToLower := strings.ToLower(description) for _, keyword := range keywords { pattern := "\\b" + keyword + "\\b" match, _ := regexp.MatchString(pattern, descriptionToLower) if match { - return true + return keyword } } - return false + return "" } type JobInfoGetter func(string, string) (string, error) @@ -43,7 +43,9 @@ func FilterInterest(proxyUrl string, possibleJobs []job.Job, jobInfoGetter JobIn if err != nil { fmt.Println(err) } - if CheckIfInterested(description) { + + possibleJob.Keyword = CheckIfInterested(description) + if possibleJob.Keyword != "" { interestingJobs = append(interestingJobs, possibleJob) } goroutineCount-- diff --git a/scraper/interest/interest_test.go b/scraper/interest/interest_test.go index 9ff9113..6c46f75 100644 --- a/scraper/interest/interest_test.go +++ b/scraper/interest/interest_test.go @@ -10,37 +10,37 @@ func TestCheckIfInterested(t *testing.T) { tests := []struct { name string description string - want bool + want string }{ { name: "contains typescript", description: "This is a job for a TypeScript developer", - want: true, + want: "typescript", }, { name: "contains node", description: "This is a job for a Node.js developer", - want: true, + want: "node", }, { name: "contains go", description: "This is a job for a Go developer", - want: true, + want: "go", }, { name: "contains go", description: "This is a job for go.", - want: true, + want: "go", }, { name: "contains django", description: "This is a job for a django developer in Chicago", - want: false, + want: "", }, { name: "does not contain keyword", description: "This is a job for a Python developer", - want: false, + want: "", }, } diff --git a/scraper/job/job.go b/scraper/job/job.go index f51a91d..f6508b3 100644 --- a/scraper/job/job.go +++ b/scraper/job/job.go @@ -15,6 +15,7 @@ type Job struct { Title string Company string Link string + Keyword string } type Response struct { diff --git a/scraper/remotive/remotive.go b/scraper/remotive/remotive.go index 8cbf438..e44693f 100644 --- a/scraper/remotive/remotive.go +++ b/scraper/remotive/remotive.go @@ -76,11 +76,13 @@ func ScanNewJobs(baseURL string, proxyUrl string) []job.Job { log.Println("Remotive total jobs found", len(remotiveJobs)) var interestingJobs []job.Job for _, newJob := range remotiveJobs { - if interest.CheckIfInterested(newJob.Description) { + keyword := interest.CheckIfInterested(newJob.Description) + if keyword != "" { interestingJobs = append(interestingJobs, job.Job{ Title: newJob.Title, Link: newJob.URL, Company: newJob.CompanyName, + Keyword: keyword, }) } }