Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
notifications-bot
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
archives
notifications-bot
Commits
0a87aec9
Commit
0a87aec9
authored
Jan 19, 2022
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Gofunc for notify, set toSend properly, fix unsent handling
parent
5a79c512
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!32
Release
,
!27
Gofunc for notify, set toSend properly, fix unsent handling
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
notifications/notifications.go
+9
-7
9 additions, 7 deletions
notifications/notifications.go
storage/database.go
+1
-1
1 addition, 1 deletion
storage/database.go
with
10 additions
and
8 deletions
notifications/notifications.go
+
9
−
7
View file @
0a87aec9
...
...
@@ -188,16 +188,15 @@ func (nb *Impl) SendBatch(data map[int64][]*notifications.Data) ([]*notification
var
ephemerals
[]
int64
var
unsent
[]
*
notifications
.
Data
for
i
,
ilist
:=
range
data
{
var
overflow
,
t
rimme
d
[]
*
notifications
.
Data
var
overflow
,
t
oSen
d
[]
*
notifications
.
Data
if
len
(
data
)
>
nb
.
maxNotifications
{
overflow
=
ilist
[
nb
.
maxNotifications
:
]
trimmed
=
ilist
[
:
nb
.
maxNotifications
]
toSend
=
ilist
[
:
nb
.
maxNotifications
]
}
else
{
toSend
=
ilist
[
:
]
}
notifs
,
rest
:=
notifications
.
BuildNotificationCSV
(
trimmed
,
nb
.
maxPayloadBytes
-
len
([]
byte
(
notificationsTag
)))
for
_
,
nd
:=
range
rest
{
nb
.
Storage
.
GetNotificationBuffer
()
.
Add
(
id
.
Round
(
nd
.
RoundID
),
[]
*
notifications
.
Data
{
nd
})
}
notifs
,
rest
:=
notifications
.
BuildNotificationCSV
(
toSend
,
nb
.
maxPayloadBytes
-
len
([]
byte
(
notificationsTag
)))
overflow
=
append
(
overflow
,
rest
...
)
csvs
[
i
]
=
string
(
notifs
)
ephemerals
=
append
(
ephemerals
,
i
)
...
...
@@ -208,7 +207,10 @@ func (nb *Impl) SendBatch(data map[int64][]*notifications.Data) ([]*notification
return
nil
,
errors
.
WithMessage
(
err
,
"Failed to get list of tokens to notify"
)
}
for
_
,
n
:=
range
toNotify
{
nb
.
notify
(
csvs
[
n
.
EphemeralId
],
n
)
tn
:=
n
go
func
()
{
nb
.
notify
(
csvs
[
tn
.
EphemeralId
],
tn
)
}()
}
return
unsent
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
storage/database.go
+
1
−
1
View file @
0a87aec9
...
...
@@ -138,7 +138,7 @@ func newDatabase(username, password, dbName, address,
// Initialize the database schema
// WARNING: Order is important. Do not change without database testing
models
:=
[]
interface
{}{
&
User
{},
&
Ephemeral
{}}
models
:=
[]
interface
{}{
&
User
{},
&
Ephemeral
{}
,
&
State
{}
}
for
_
,
model
:=
range
models
{
err
=
db
.
AutoMigrate
(
model
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment