diff --git a/jobNotifier/discord/discord.go b/jobNotifier/discord/discord.go index ccc7277..dc6f716 100644 --- a/jobNotifier/discord/discord.go +++ b/jobNotifier/discord/discord.go @@ -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("```") diff --git a/jobNotifier/discord/discord_test.go b/jobNotifier/discord/discord_test.go index 69c1667..eda0712 100644 --- a/jobNotifier/discord/discord_test.go +++ b/jobNotifier/discord/discord_test.go @@ -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 @@ -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) { diff --git a/jobNotifier/dynamo/dynamo.go b/jobNotifier/dynamo/dynamo.go index 39b00d1..75b3e1d 100644 --- a/jobNotifier/dynamo/dynamo.go +++ b/jobNotifier/dynamo/dynamo.go @@ -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