@@ -499,6 +499,36 @@ def _log(self, message, *args, level='INFO'):
499499 'level' : level ,
500500 })
501501
502+ def _add_missing_slots (self ):
503+ missing_trigger_ids = self .env ['runbot.trigger' ].search ([
504+ ('project_id' , '=' , self .bundle_id .project_id .id ),
505+ ('category_id' , '=' , self .category_id .id ),
506+ ('id' , 'not in' , self .slot_ids .trigger_id .ids )
507+ ]).filtered (
508+ lambda t : not t .version_domain or
509+ self .bundle_id .version_id .filtered_domain (t ._get_version_domain ())
510+ )
511+ bundle = self .bundle_id
512+ dockerfile_id = bundle .dockerfile_id or bundle .base_id .dockerfile_id or bundle .project_id .dockerfile_id or bundle .version_id .dockerfile_id
513+ for trigger in missing_trigger_ids :
514+ params_value = {
515+ 'version_id' : self .bundle_id .version_id .id ,
516+ 'project_id' : self .bundle_id .project_id .id ,
517+ 'create_batch_id' : self .id ,
518+ 'config_id' : trigger .config_id .id ,
519+ 'trigger_id' : trigger .id ,
520+ 'config_data' : dict (trigger .config_data or {}),
521+ 'modules' : bundle .modules ,
522+ 'dockerfile_id' : dockerfile_id .id ,
523+ 'commit_link_ids' : [(6 , 0 , self .commit_link_ids .ids )],
524+ }
525+ params = self .env ['runbot.build.params' ].create (params_value )
526+ self .env ['runbot.batch.slot' ].create ({
527+ 'batch_id' : self .id ,
528+ 'trigger_id' : trigger .id ,
529+ 'params_id' : params .id ,
530+ 'link_type' : 'created' ,
531+ })
502532
503533class BatchLog (models .Model ):
504534 _name = 'runbot.batch.log'
0 commit comments