Skip to content

Commit

Permalink
trim summary
Browse files Browse the repository at this point in the history
  • Loading branch information
tillkuhn committed Jan 29, 2024
1 parent f5b372f commit d15b47d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions go/remindabot/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (

require (
github.com/antihax/optional v1.0.0 // indirect
github.com/cdfmlr/ellipsis v0.0.1 // indirect
github.com/confluentinc/kafka-rest-sdk-go/kafkarestv3 v0.3.18 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/eapache/go-resiliency v1.5.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go/remindabot/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cdfmlr/ellipsis v0.0.1 h1:4pwrPbKPMd4mXSdJA4CSRjgEzCbXyRiFBkmgg2KclBI=
github.com/cdfmlr/ellipsis v0.0.1/go.mod h1:hulYx9m/7Edoo2AkRzkJ/YPDlLB45BgjitI3z0sMVFI=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down
3 changes: 3 additions & 0 deletions go/remindabot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/cdfmlr/ellipsis"
"github.com/cloudevents/sdk-go/v2/event"
"github.com/segmentio/kafka-go"
"github.com/tillkuhn/rubin/pkg/polly"
Expand Down Expand Up @@ -130,6 +131,8 @@ func main() {
// with i,note syntax, note would just be a copy, use index to access the actual list item
// Ref.: https://yourbasic.org/golang/gotcha-change-value-range/
for i := range notes {
// if summary is longer, end with ... (which add to the total length)
notes[i].Summary = ellipsis.Ending(notes[i].Summary, 72)
if strings.Contains(notes[i].UserName, " ") {
names := strings.Split(notes[i].UserName, " ")
if len(names[1]) >= 1 {
Expand Down
5 changes: 5 additions & 0 deletions go/remindabot/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"github.com/cdfmlr/ellipsis"
"github.com/cloudevents/sdk-go/v2/event"
"io"
"net/http"
Expand Down Expand Up @@ -40,6 +41,10 @@ func TestConfig(t *testing.T) {
}
}

func TestEllipsis(t *testing.T) {
str := "net.timafe.event.system.renew-cert.v1"
assert.Equal(t, "....system.renew-cert.v1", ellipsis.Starting(str, 24))
}
func TestAddTagJPEG(t *testing.T) {
actual := mailSubject()
wd := time.Now().Weekday().String()
Expand Down

0 comments on commit d15b47d

Please sign in to comment.