Merge branch 'main' of https://github.com/donetick/donetick
This commit is contained in:
commit
3ce26c906f
3 changed files with 78 additions and 36 deletions
29
.github/workflows/go-build.yml
vendored
29
.github/workflows/go-build.yml
vendored
|
@ -1,13 +1,12 @@
|
||||||
name: Build
|
name: Test and Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches: [ "main", "develop" ]
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main", "develop" ]
|
branches: [ "main" ]
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
@ -15,7 +14,21 @@ jobs:
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '1.23'
|
go-version: '1.22'
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: go test ./...
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: '1.22'
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build -v ./...
|
run: go build -v ./...
|
48
.golangci.yaml
Normal file
48
.golangci.yaml
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
run:
|
||||||
|
timeout: 5m
|
||||||
|
tests: true
|
||||||
|
|
||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- govet
|
||||||
|
- errcheck
|
||||||
|
- staticcheck
|
||||||
|
- gosimple
|
||||||
|
- unused
|
||||||
|
- ineffassign
|
||||||
|
- unused
|
||||||
|
- typecheck
|
||||||
|
- gofmt
|
||||||
|
- goimports
|
||||||
|
- gocyclo
|
||||||
|
- dupl
|
||||||
|
- misspell
|
||||||
|
- unconvert
|
||||||
|
- nakedret
|
||||||
|
- goconst
|
||||||
|
- gocritic
|
||||||
|
|
||||||
|
linters-settings:
|
||||||
|
gofmt:
|
||||||
|
simplify: true
|
||||||
|
|
||||||
|
gocyclo:
|
||||||
|
min-complexity: 15
|
||||||
|
|
||||||
|
dupl:
|
||||||
|
threshold: 100
|
||||||
|
|
||||||
|
misspell:
|
||||||
|
locale: US
|
||||||
|
|
||||||
|
issues:
|
||||||
|
exclude-use-default: false
|
||||||
|
max-issues-per-linter: 0
|
||||||
|
max-same-issues: 0
|
||||||
|
exclude-rules:
|
||||||
|
- linters:
|
||||||
|
- errcheck
|
||||||
|
text: ".*error return value not checked.*"
|
||||||
|
- linters:
|
||||||
|
- dupl
|
||||||
|
text: ".*duplicate of.*"
|
|
@ -30,7 +30,7 @@ func (n *NotificationPlanner) GenerateNotifications(c context.Context, chore *ch
|
||||||
circleMembers, err := n.cRepo.GetCircleUsers(c, chore.CircleID)
|
circleMembers, err := n.cRepo.GetCircleUsers(c, chore.CircleID)
|
||||||
assignees := make([]*cModel.UserCircleDetail, 0)
|
assignees := make([]*cModel.UserCircleDetail, 0)
|
||||||
for _, member := range circleMembers {
|
for _, member := range circleMembers {
|
||||||
if member.ID == chore.AssignedTo {
|
if member.UserID == chore.AssignedTo {
|
||||||
assignees = append(assignees, member)
|
assignees = append(assignees, member)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,14 +71,7 @@ func (n *NotificationPlanner) GenerateNotifications(c context.Context, chore *ch
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateDueNotifications(chore *chModel.Chore, users []*cModel.UserCircleDetail) []*nModel.Notification {
|
func generateDueNotifications(chore *chModel.Chore, users []*cModel.UserCircleDetail) []*nModel.Notification {
|
||||||
var assignee *cModel.UserCircleDetail
|
|
||||||
notifications := make([]*nModel.Notification, 0)
|
notifications := make([]*nModel.Notification, 0)
|
||||||
for _, user := range users {
|
|
||||||
if user.ID == chore.AssignedTo {
|
|
||||||
assignee = user
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
notification := &nModel.Notification{
|
notification := &nModel.Notification{
|
||||||
ChoreID: chore.ID,
|
ChoreID: chore.ID,
|
||||||
|
@ -86,9 +79,9 @@ func generateDueNotifications(chore *chModel.Chore, users []*cModel.UserCircleDe
|
||||||
ScheduledFor: *chore.NextDueDate,
|
ScheduledFor: *chore.NextDueDate,
|
||||||
CreatedAt: time.Now().UTC(),
|
CreatedAt: time.Now().UTC(),
|
||||||
TypeID: user.NotificationType,
|
TypeID: user.NotificationType,
|
||||||
UserID: user.ID,
|
UserID: user.UserID,
|
||||||
TargetID: user.TargetID,
|
TargetID: user.TargetID,
|
||||||
Text: fmt.Sprintf("📅 Reminder: *%s* is due today and assigned to %s.", chore.Name, assignee.DisplayName),
|
Text: fmt.Sprintf("📅 Reminder: *%s* is due today and assigned to %s.", chore.Name, user.DisplayName),
|
||||||
}
|
}
|
||||||
if notification.IsValid() {
|
if notification.IsValid() {
|
||||||
notifications = append(notifications, notification)
|
notifications = append(notifications, notification)
|
||||||
|
@ -99,13 +92,7 @@ func generateDueNotifications(chore *chModel.Chore, users []*cModel.UserCircleDe
|
||||||
}
|
}
|
||||||
|
|
||||||
func generatePreDueNotifications(chore *chModel.Chore, users []*cModel.UserCircleDetail) []*nModel.Notification {
|
func generatePreDueNotifications(chore *chModel.Chore, users []*cModel.UserCircleDetail) []*nModel.Notification {
|
||||||
var assignee *cModel.UserCircleDetail
|
|
||||||
for _, user := range users {
|
|
||||||
if user.ID == chore.AssignedTo {
|
|
||||||
assignee = user
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
notifications := make([]*nModel.Notification, 0)
|
notifications := make([]*nModel.Notification, 0)
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
notification := &nModel.Notification{
|
notification := &nModel.Notification{
|
||||||
|
@ -114,9 +101,9 @@ func generatePreDueNotifications(chore *chModel.Chore, users []*cModel.UserCircl
|
||||||
ScheduledFor: *chore.NextDueDate,
|
ScheduledFor: *chore.NextDueDate,
|
||||||
CreatedAt: time.Now().UTC().Add(-time.Hour * 3),
|
CreatedAt: time.Now().UTC().Add(-time.Hour * 3),
|
||||||
TypeID: user.NotificationType,
|
TypeID: user.NotificationType,
|
||||||
UserID: user.ID,
|
UserID: user.UserID,
|
||||||
TargetID: user.TargetID,
|
TargetID: user.TargetID,
|
||||||
Text: fmt.Sprintf("📢 Heads up! *%s* is due soon (on %s) and assigned to %s.", chore.Name, chore.NextDueDate.Format("January 2nd"), assignee.DisplayName),
|
Text: fmt.Sprintf("📢 Heads up! *%s* is due soon (on %s) and assigned to %s.", chore.Name, chore.NextDueDate.Format("January 2nd"), user.DisplayName),
|
||||||
}
|
}
|
||||||
if notification.IsValid() {
|
if notification.IsValid() {
|
||||||
notifications = append(notifications, notification)
|
notifications = append(notifications, notification)
|
||||||
|
@ -128,13 +115,7 @@ func generatePreDueNotifications(chore *chModel.Chore, users []*cModel.UserCircl
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateOverdueNotifications(chore *chModel.Chore, users []*cModel.UserCircleDetail) []*nModel.Notification {
|
func generateOverdueNotifications(chore *chModel.Chore, users []*cModel.UserCircleDetail) []*nModel.Notification {
|
||||||
var assignee *cModel.UserCircleDetail
|
|
||||||
for _, user := range users {
|
|
||||||
if user.ID == chore.AssignedTo {
|
|
||||||
assignee = user
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
notifications := make([]*nModel.Notification, 0)
|
notifications := make([]*nModel.Notification, 0)
|
||||||
for _, hours := range []int{24, 48, 72} {
|
for _, hours := range []int{24, 48, 72} {
|
||||||
scheduleTime := chore.NextDueDate.Add(time.Hour * time.Duration(hours))
|
scheduleTime := chore.NextDueDate.Add(time.Hour * time.Duration(hours))
|
||||||
|
@ -145,9 +126,9 @@ func generateOverdueNotifications(chore *chModel.Chore, users []*cModel.UserCirc
|
||||||
ScheduledFor: scheduleTime,
|
ScheduledFor: scheduleTime,
|
||||||
CreatedAt: time.Now().UTC(),
|
CreatedAt: time.Now().UTC(),
|
||||||
TypeID: user.NotificationType,
|
TypeID: user.NotificationType,
|
||||||
UserID: user.ID,
|
UserID: user.UserID,
|
||||||
TargetID: fmt.Sprint(user.TargetID),
|
TargetID: fmt.Sprint(user.TargetID),
|
||||||
Text: fmt.Sprintf("🚨 *%s* is now %d hours overdue. Please complete it as soon as possible. (Assigned to %s)", chore.Name, hours, assignee.DisplayName),
|
Text: fmt.Sprintf("🚨 *%s* is now %d hours overdue. Please complete it as soon as possible. (Assigned to %s)", chore.Name, hours, user.DisplayName),
|
||||||
}
|
}
|
||||||
if notification.IsValid() {
|
if notification.IsValid() {
|
||||||
notifications = append(notifications, notification)
|
notifications = append(notifications, notification)
|
||||||
|
|
Loading…
Add table
Reference in a new issue