@@ -78,18 +78,6 @@ func (*Profile) Indexes() []mongo.IndexModel {
7878
7979var isArrayWContent = bson.M {"$not" : bson.M {"$size" : 0 }, "$type" : "array" }
8080
81- func actualActiveProfilesFilter () bson.M {
82- return bson.M {
83- "active" : true ,
84- "$or" : []bson.M {
85- {"desiredProfessions" : isArrayWContent },
86- {"professionExperienced" : isArrayWContent },
87- {"driversLicenses" : isArrayWContent },
88- {"educations" : isArrayWContent },
89- },
90- }
91- }
92-
9381// GetListsProfiles returns all profiles that can be used for the cv lists functionality
9482func GetListsProfiles (conn db.Connection ) ([]Profile , error ) {
9583 profiles := []Profile {}
@@ -101,18 +89,32 @@ func GetListsProfiles(conn db.Connection) ([]Profile, error) {
10189 return profiles , err
10290}
10391
104- // GetActualActiveProfiles returns that we can actually use
92+ func actualActiveMatchProfilesFilter () bson.M {
93+ return bson.M {
94+ "active" : true ,
95+ "$or" : []bson.M {
96+ {"desiredProfessions" : isArrayWContent },
97+ {"professionExperienced" : isArrayWContent },
98+ {"driversLicenses" : isArrayWContent },
99+ {"educations" : isArrayWContent },
100+ },
101+ // we use $not here as there are properties without this property and with `$not: true` we match `false`, `undefined` and `null
102+ "listsAllowed" : bson.M {"$not" : bson.M {"$eq" : true }},
103+ }
104+ }
105+
106+ // GetActualMatchActiveProfiles returns that we can actually use
105107// Matches are not really helpfull if no desiredProfessions, professionExperienced, driversLicenses or educations is set
106108// Matches without an onMatch property are useless as we can't send the match anywhere
107- func GetActualActiveProfiles (conn db.Connection ) ([]Profile , error ) {
109+ func GetActualMatchActiveProfiles (conn db.Connection ) ([]Profile , error ) {
108110 profiles := []Profile {}
109- err := conn .Find (& Profile {}, & profiles , actualActiveProfilesFilter ())
111+ err := conn .Find (& Profile {}, & profiles , actualActiveMatchProfilesFilter ())
110112 return profiles , err
111113}
112114
113- // GetActualActiveProfilesCount does the same as GetActualActiveProfiles but only returns the number of found profiles
114- func GetActualActiveProfilesCount (conn db.Connection ) (uint64 , error ) {
115- return conn .Count (& Profile {}, actualActiveProfilesFilter ())
115+ // GetActualMatchActiveProfilesCount does the same as GetActualMatchActiveProfiles but only returns the number of found profiles
116+ func GetActualMatchActiveProfilesCount (conn db.Connection ) (uint64 , error ) {
117+ return conn .Count (& Profile {}, actualActiveMatchProfilesFilter ())
116118}
117119
118120// GetProfiles returns all profiles from the database
0 commit comments