Skip to content

Commit

Permalink
Merge pull request #36 from signaux-faibles/feat/multiple-siret-lookup
Browse files Browse the repository at this point in the history
Feat/multiple siret lookup
  • Loading branch information
chrnin authored Jul 9, 2023
2 parents bb752f3 + e0cd2a3 commit 11c3586
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion cards.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ func (wekan *Wekan) BuildDomainCardsPipeline() Pipeline {
}

func (wekan *Wekan) BuildCardFromCustomTextFieldPipeline(name string, value string) Pipeline {
return wekan.BuildCardFromCustomTextFieldsPipeline(name, []string{value})
}

func (wekan *Wekan) BuildCardFromCustomTextFieldsPipeline(name string, values []string) Pipeline {
matchNameStage := bson.M{
"$match": bson.M{
"name": name,
Expand Down Expand Up @@ -356,7 +360,7 @@ func (wekan *Wekan) BuildCardFromCustomTextFieldPipeline(name string, value stri
"$eq": bson.A{"$customField._id", "$$customFieldId"},
},
bson.M{
"$eq": bson.A{"$customField.value", value},
"$in": bson.A{"$customField.value", values},
},
},
},
Expand Down Expand Up @@ -432,3 +436,38 @@ func (wekan *Wekan) UnarchiveCard(ctx context.Context, cardID CardID) error {
}
return nil
}

func (config *Config) CustomFieldWithName(card Card, name string) string {
configBoard := config.Boards[card.BoardID]
for _, customField := range card.CustomFields {
if configBoard.CustomFields[customField.ID].Name == name {
return customField.Value
}
}
return ""
}

// TODO: écrire un test
func (wekan *Wekan) UpdateCardDescription(ctx context.Context, cardID CardID, description string) error {
stats, err := wekan.db.Collection("cards").UpdateOne(ctx,
bson.M{"_id": cardID},
bson.M{
"$set": bson.M{
"description": description,
},
"$currentDate": bson.M{
"modifiedAt": true,
},
},
)
if stats.MatchedCount == 0 {
return CardNotFoundError{cardID: cardID}
}
if stats.ModifiedCount == 0 {
return NothingDoneError{}
}
if err != nil {
return UnexpectedMongoError{err: err}
}
return nil
}

0 comments on commit 11c3586

Please sign in to comment.