Skip to content

Commit

Permalink
Merge pull request #21 from austin1237/keyword
Browse files Browse the repository at this point in the history
keyword is now displayed in discord
  • Loading branch information
austin1237 authored Apr 24, 2024
2 parents 8f5b887 + 70e1af2 commit b02528f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion jobNotifier/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ func generateMessages(jobs []job.Job) []string {
message.WriteString("```")

for _, job := range jobs {
newLine := job.Link + ", " + job.Company + "\n"
newLine := job.Link + ", " + job.Company
if job.Keyword != "" {
newLine += ", " + job.Keyword
}

newLine += "\n"
// Discord has a 2000 character limit for messages
if message.Len()+len(newLine)+3 >= 2000 { // +3 for the ending "```"
message.WriteString("```")
Expand Down
5 changes: 4 additions & 1 deletion jobNotifier/discord/discord_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func TestGenerateMessages(t *testing.T) {
jobs := []job.Job{
{Link: "http://example.com/job1", Company: "Company1"},
{Link: "http://example.com/job1", Company: "Company1", Keyword: "Go"},
{Link: "http://example.com/job2", Company: "Company2"},
{Link: "http://example.com/job3", Company: "Company3"},
// Add more jobs to test the 2000 character limit
Expand All @@ -26,6 +26,9 @@ func TestGenerateMessages(t *testing.T) {
// Check that all jobs are included in the messages
for _, job := range jobs {
jobLine := job.Link + ", " + job.Company
if job.Keyword != "" {
jobLine += ", " + job.Keyword
}
found := false
for _, message := range messages {
if strings.Contains(message, jobLine) {
Expand Down
4 changes: 2 additions & 2 deletions jobNotifier/dynamo/dynamo.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func (t *Table) ReadItem(company string) (string, error) {
}

func (t *Table) WriteItems(companies []string) {
// Set the ttl time to 30 days from now
expirationTime := time.Now().AddDate(0, 1, 0).Unix()
// Set the ttl time to 60 days from now
expirationTime := time.Now().AddDate(0, 2, 0).Unix()

// Create a wait group
var wg sync.WaitGroup
Expand Down

0 comments on commit b02528f

Please sign in to comment.