Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
98922e4f
Commit
98922e4f
authored
9 months ago
by
Anton Sattarov
Committed by
Pavel Antonov
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Исправлена ошибка при которой не передавались переводы при пакетной обработке элементов коллекций
parent
e85e37a7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/items/pagination.go
+6
-13
6 additions, 13 deletions
pkg/items/pagination.go
pkg/items/pagination_test.go
+36
-0
36 additions, 0 deletions
pkg/items/pagination_test.go
with
42 additions
and
13 deletions
pkg/items/pagination.go
+
6
−
13
View file @
98922e4f
...
...
@@ -27,33 +27,26 @@ func (b *BatchProcessor) getBatch(ctx context.Context) ([]*Item, bool, error) {
var
total
int
if
b
.
FindPublishedOptions
!=
nil
{
opts
:=
*
b
.
FindPublishedOptions
opts
.
FindOptions
=
*
options
.
New
(
b
.
processed
,
b
.
limit
,
b
.
sort
...
)
res
,
total
,
err
=
b
.
Items
.
FindPublished
(
ctx
,
b
.
SpaceID
,
b
.
EnvID
,
b
.
CollectionID
,
b
.
Filter
,
&
FindPublishedOptions
{
Regular
:
b
.
FindPublishedOptions
.
Regular
,
Hidden
:
b
.
FindPublishedOptions
.
Hidden
,
Templates
:
b
.
FindPublishedOptions
.
Templates
,
FindOptions
:
*
options
.
New
(
b
.
processed
,
b
.
limit
,
b
.
sort
...
),
},
&
opts
,
)
}
else
{
opts
:=
*
b
.
FindOptions
opts
.
FindOptions
=
*
options
.
New
(
b
.
processed
,
b
.
limit
,
b
.
sort
...
)
res
,
total
,
err
=
b
.
Items
.
Find
(
ctx
,
b
.
SpaceID
,
b
.
EnvID
,
b
.
CollectionID
,
b
.
Filter
,
&
FindOptions
{
Deleted
:
b
.
FindOptions
.
Deleted
,
Regular
:
b
.
FindOptions
.
Regular
,
Hidden
:
b
.
FindOptions
.
Hidden
,
Templates
:
b
.
FindOptions
.
Templates
,
FindOptions
:
*
options
.
New
(
b
.
processed
,
b
.
limit
,
b
.
sort
...
),
},
&
opts
,
)
}
...
...
This diff is collapsed.
Click to expand it.
pkg/items/pagination_test.go
+
36
−
0
View file @
98922e4f
...
...
@@ -5,6 +5,7 @@ import (
"testing"
"git.perx.ru/perxis/perxis-go/pkg/environments"
"git.perx.ru/perxis/perxis-go/pkg/errors"
"git.perx.ru/perxis/perxis-go/pkg/options"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
...
...
@@ -58,4 +59,39 @@ func TestBatchProcessor(t *testing.T) {
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
1000
/
25
,
counter
)
})
t
.
Run
(
"With FindOptions2"
,
func
(
t
*
testing
.
T
)
{
f
:=
&
FindOptions
{
Deleted
:
true
,
Hidden
:
true
,
Regular
:
true
,
Templates
:
true
,
TranslationsIDs
:
[]
string
{
"*"
},
LocaleID
:
"en"
,
}
itemssvc
:=
&
Stub
{
FindResult
:
func
(
req
StubFindRequest
)
StubFindResult
{
fo
:=
req
.
Options
[
0
]
if
!
assert
.
Equal
(
t
,
f
,
fo
)
{
return
StubFindResult
{
Items
:
nil
,
Total
:
0
,
Error
:
errors
.
New
(
"FindOptions not equal"
)}
}
return
StubFindResult
{
Items
:
make
([]
*
Item
,
fo
.
Limit
),
Total
:
25
,
Error
:
nil
}
},
}
f
.
FindOptions
=
*
options
.
New
(
0
,
25
)
b
:=
&
BatchProcessor
{
Items
:
itemssvc
,
SpaceID
:
"sp"
,
EnvID
:
environments
.
DefaultEnvironment
,
CollectionID
:
"col"
,
FindOptions
:
f
,
}
var
counter
int
_
,
err
:=
b
.
Do
(
context
.
Background
(),
func
(
batch
[]
*
Item
)
error
{
counter
++
;
return
nil
})
require
.
NoError
(
t
,
err
)
})
}
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