diff --git a/cards.go b/cards.go index 07c3f20..3a7e24d 100644 --- a/cards.go +++ b/cards.go @@ -153,7 +153,7 @@ func (wekan *Wekan) SelectCardsFromListID(ctx context.Context, listID ListID) ([ return wekan.SelectCardsFromQuery(ctx, bson.M{"listId": listID}) } -// SelectCardsWithCommentsFromPipeline retourne les objets correspondant au modèle Card à partir d'un pipeline mongodb +// SelectCardsFromPipeline retourne les objets correspondant au modèle Card à partir d'un pipeline mongodb func (wekan *Wekan) SelectCardsFromPipeline(ctx context.Context, collection string, pipeline Pipeline) ([]Card, error) { cur, err := wekan.db.Collection(collection).Aggregate(ctx, pipeline) if err != nil { @@ -413,8 +413,8 @@ func (wekan *Wekan) BuildCardFromCustomTextFieldPipeline(name string, value stri return pipeline } -func (w *Wekan) UnarchiveCard(ctx context.Context, cardID CardID) error { - update, err := w.db.Collection("cards").UpdateOne(ctx, bson.M{ +func (wekan *Wekan) UnarchiveCard(ctx context.Context, cardID CardID) error { + update, err := wekan.db.Collection("cards").UpdateOne(ctx, bson.M{ "_id": cardID, }, bson.M{ "$set": bson.M{ diff --git a/cards_test.go b/cards_test.go index add4d39..f37d890 100644 --- a/cards_test.go +++ b/cards_test.go @@ -10,8 +10,8 @@ func TestCard_AddMember(t *testing.T) { BoardID(t.Name()+"boardID"), ListID(t.Name()+"boardID"), SwimlaneID(t.Name()+"boardID"), - (t.Name() + "title"), - (t.Name() + "description"), + t.Name()+"title", + t.Name()+"description", UserID(t.Name()+"userID"), ) memberID := UserID(t.Name() + "memberID") @@ -24,8 +24,8 @@ func TestCard_AddMember_Duplicate(t *testing.T) { BoardID(t.Name()+"boardID"), ListID(t.Name()+"boardID"), SwimlaneID(t.Name()+"boardID"), - (t.Name() + "title"), - (t.Name() + "description"), + t.Name()+"title", + t.Name()+"description", UserID(t.Name()+"userID"), ) memberID := UserID(t.Name() + "memberID") diff --git a/init.go b/init.go index 81af4ee..4c2a67d 100644 --- a/init.go +++ b/init.go @@ -47,7 +47,7 @@ func (wekan *Wekan) AssertPrivileged(ctx context.Context) error { if *wekan.privileged { return nil } - return NotPrivilegedError{wekan.adminUserID, errors.New("L'utilisateur n'est pas administration")} + return NotPrivilegedError{wekan.adminUserID, errors.New("l'utilisateur n'est pas administrateur")} } admin, err := wekan.GetUserFromUsername(ctx, wekan.adminUsername) if err != nil { diff --git a/misc.go b/misc.go index f7dc1eb..958faa8 100644 --- a/misc.go +++ b/misc.go @@ -1,96 +1,96 @@ package libwekan import ( - "math/rand" - "time" + "math/rand" + "time" ) func newId() string { - return newIdN(17) + return newIdN(17) } func newId6() string { - return newIdN(6) + return newIdN(6) } func newIdN(n int) string { - chars := "123456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz" - l := len(chars) - var digits []byte - for i := 0; i < n; i++ { - digit := rand.Intn(l) - digits = append(digits, chars[digit]) - } - return string(digits) + chars := "123456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz" + l := len(chars) + var digits []byte + for i := 0; i < n; i++ { + digit := rand.Intn(l) + digits = append(digits, chars[digit]) + } + return string(digits) } func uniq[Element comparable](array []Element) []Element { - m := make(map[Element]struct{}) - for _, element := range array { - m[element] = struct{}{} - } - var set = []Element{} - for element := range m { - set = append(set, element) - } - return set + m := make(map[Element]struct{}) + for _, element := range array { + m[element] = struct{}{} + } + var set []Element + for element := range m { + set = append(set, element) + } + return set } func intersect[E comparable](elementsA []E, elementsB []E) (both []E, onlyA []E, onlyB []E) { - for _, elementA := range elementsA { - foundBoth := false - for _, elementB := range elementsB { - if elementA == elementB { - both = append(both, elementA) - foundBoth = true - } - } - if !foundBoth { - onlyA = append(onlyA, elementA) - } - } + for _, elementA := range elementsA { + foundBoth := false + for _, elementB := range elementsB { + if elementA == elementB { + both = append(both, elementA) + foundBoth = true + } + } + if !foundBoth { + onlyA = append(onlyA, elementA) + } + } - for _, elementB := range elementsB { - foundBoth := false - for _, elementA := range elementsA { - if elementA == elementB { - foundBoth = true - } - } - if !foundBoth { - onlyB = append(onlyB, elementB) - } - } - return both, onlyA, onlyB + for _, elementB := range elementsB { + foundBoth := false + for _, elementA := range elementsA { + if elementA == elementB { + foundBoth = true + } + } + if !foundBoth { + onlyB = append(onlyB, elementB) + } + } + return both, onlyA, onlyB } func mapSlice[T any, M any](a []T, f func(T) M) []M { - n := make([]M, len(a)) - for i, e := range a { - n[i] = f(e) - } - return n + n := make([]M, len(a)) + for i, e := range a { + n[i] = f(e) + } + return n } func toMongoTime(t time.Time) time.Time { - return t.In(time.UTC).Truncate(time.Millisecond) + return t.In(time.UTC).Truncate(time.Millisecond) } func contains[Element comparable](elements []Element, element Element) bool { - for _, actual := range elements { - if element == actual { - return true - } - } - return false + for _, actual := range elements { + if element == actual { + return true + } + } + return false } func selectSlice[Element any](slice []Element, filter func(Element) bool) []Element { - var accepted []Element - for _, element := range slice { - if filter(element) { - accepted = append(accepted, element) - } - } - return accepted + var accepted []Element + for _, element := range slice { + if filter(element) { + accepted = append(accepted, element) + } + } + return accepted } diff --git a/pipeline.go b/pipeline.go index ee0e1da..2f42bd0 100644 --- a/pipeline.go +++ b/pipeline.go @@ -9,7 +9,7 @@ func (p *Pipeline) AppendStage(stage bson.M) { } func (p *Pipeline) PrependStage(stage bson.M) { - *p = append(Pipeline{stage}, (*p)...) + *p = append(Pipeline{stage}, *p...) } func (p *Pipeline) AppendPipeline(pipeline Pipeline) { @@ -17,5 +17,5 @@ func (p *Pipeline) AppendPipeline(pipeline Pipeline) { } func (p *Pipeline) PrependPipeline(pipeline Pipeline) { - *p = append(pipeline, (*p)...) + *p = append(pipeline, *p...) } diff --git a/users.go b/users.go index aff3745..9bc8478 100644 --- a/users.go +++ b/users.go @@ -92,12 +92,12 @@ type UserProfile struct { type Username string type UserID string -func (userID UserID) GetDocument(ctx context.Context, wekan *Wekan) (User, error) { - return wekan.GetUserFromID(ctx, userID) +func (userId UserID) GetDocument(ctx context.Context, wekan *Wekan) (User, error) { + return wekan.GetUserFromID(ctx, userId) } -func (userID UserID) Check(ctx context.Context, wekan *Wekan) error { - _, err := wekan.GetUserFromID(ctx, userID) +func (userId UserID) Check(ctx context.Context, wekan *Wekan) error { + _, err := wekan.GetUserFromID(ctx, userId) return err } diff --git a/users_integration_test.go b/users_integration_test.go index 018db6c..2066306 100644 --- a/users_integration_test.go +++ b/users_integration_test.go @@ -1,5 +1,4 @@ //go:build integration -// +build integration // nolint:errcheck package libwekan