Commit f65074a 1 parent badc3d7 commit f65074a Copy full SHA for f65074a
File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,19 @@ function db_fetch_groups($year) {
127
127
->findByYear ($ year , ['group_number ' => 'ASC ' ]);
128
128
}
129
129
130
+ function db_fetch_groups_by_repo ($ year , $ repo ) {
131
+ global $ entityManager ;
132
+ return $ entityManager ->createQueryBuilder ()
133
+ ->from ('ProjGroup ' , 'g ' )
134
+ ->select ('g ' )
135
+ ->where ('g.year = :year ' )
136
+ ->andWhere ('g.repository = :repo ' )
137
+ ->setParameter ('year ' , $ year )
138
+ ->setParameter ('repo ' , $ repo )
139
+ ->getQuery ()
140
+ ->getArrayResult ();
141
+ }
142
+
130
143
function db_fetch_group ($ year , $ number ) : ?ProjGroup {
131
144
global $ entityManager ;
132
145
return $ entityManager ->getRepository ('ProjGroup ' )
Original file line number Diff line number Diff line change @@ -130,12 +130,23 @@ public function __toString() {
130
130
return (string )$ this ->group_number ;
131
131
}
132
132
133
+ public function set_repository ($ url ) {
134
+ $ new_repo = $ url ? Repository::factory ($ url ) : '' ;
135
+ // max 5 groups per repo
136
+ if ($ new_repo && $ new_repo != $ this ->repository ) {
137
+ if (sizeof (db_fetch_groups_by_repo ($ this ->year , $ new_repo )) >= 5 ) {
138
+ throw new ValidationException (
139
+ 'Exceed the maximum number of groups per repository ' );
140
+ }
141
+ }
142
+ $ this ->repository = $ new_repo ;
143
+ }
144
+
133
145
public function getstr_repository () { return $ this ->repository ? (string )$ this ->getRepository () : '' ; }
134
146
public function set_project_name ($ name ) { $ this ->project_name = $ name ; }
135
147
public function set_project_description ($ description ) { $ this ->project_description = $ description ; }
136
148
public function set_project_website ($ url ) { $ this ->project_website = check_url ($ url ); }
137
149
public function set_major_users ($ users ) { $ this ->major_users = $ users ; }
138
- public function set_repository ($ url ) { $ this ->repository = $ url ? Repository::factory ($ url ) : '' ; }
139
150
public function set_cla ($ cla ) { $ this ->cla = (bool )$ cla ; }
140
151
public function set_dco ($ dco ) { $ this ->dco = (bool )$ dco ; }
141
152
public function set_lines_of_code ($ number ) { $ this ->lines_of_code = (int )$ number ; }
You can’t perform that action at this time.
0 commit comments