@@ -911,10 +911,10 @@ func (c *CompaniesType) UpdateCompanyParticipationStatus(companyID primitive.Obj
911911
912912// UpdateCompanyData is the data used to update a company, using the method UpdateCompany.
913913type UpdateCompanyData struct {
914- Name * string `json:"name"`
915- Description * string `json:"description"`
916- Site * string `json:"site"`
917- LinkedIn * string `json:"linkedin"`
914+ Name * string `json:"name"`
915+ Description * string `json:"description"`
916+ Site * string `json:"site"`
917+ LinkedIn * string `json:"linkedin"`
918918 BillingInfo * models.CompanyBillingInfo `json:"billingInfo"`
919919}
920920
@@ -1434,6 +1434,52 @@ func (c *CompaniesType) DeleteCompanyParticipation(companyID primitive.ObjectID,
14341434 return & updatedCompany , nil
14351435}
14361436
1437+ // AnnounceAcceptedCompanies changes all companies with ACCEPTED status on the
1438+ // current event to ANNOUNCED. Returns the number of companies updated.
1439+ func (c * CompaniesType ) AnnounceAcceptedCompanies () (int64 , error ) {
1440+ ctx := context .Background ()
1441+
1442+ currentEvent , err := Events .GetCurrentEvent ()
1443+ if err != nil {
1444+ return 0 , err
1445+ }
1446+
1447+ filter := bson.M {
1448+ "participations" : bson.M {
1449+ "$elemMatch" : bson.M {
1450+ "event" : currentEvent .ID ,
1451+ "status" : models .Accepted ,
1452+ },
1453+ },
1454+ }
1455+
1456+ update := bson.M {
1457+ "$set" : bson.M {
1458+ "participations.$[elem].status" : models .Announced ,
1459+ },
1460+ }
1461+
1462+ arrayFilters := options.ArrayFilters {
1463+ Filters : []interface {}{
1464+ bson.M {
1465+ "elem.event" : currentEvent .ID ,
1466+ "elem.status" : models .Accepted ,
1467+ },
1468+ },
1469+ }
1470+
1471+ opts := options .Update ().SetArrayFilters (arrayFilters )
1472+
1473+ result , err := c .Collection .UpdateMany (ctx , filter , update , opts )
1474+ if err != nil {
1475+ return 0 , err
1476+ }
1477+
1478+ ResetCurrentPublicCompanies ()
1479+
1480+ return result .ModifiedCount , nil
1481+ }
1482+
14371483// FindThread finds a thread in a company
14381484func (c * CompaniesType ) FindThread (threadID primitive.ObjectID ) (* models.Company , error ) {
14391485
0 commit comments