diff options
-rwxr-xr-x | lib/mysql-functions | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/mysql-functions b/lib/mysql-functions index 67e49aa..59a649e 100755 --- a/lib/mysql-functions +++ b/lib/mysql-functions @@ -1503,3 +1503,24 @@ mysql_query_ordering_correct() { ' printf ')' } + +# mysql_determine_majority_build_slave_architecture_id +# retreive the `architectures`.`id` of the majority of the currently +# active build slaves +mysql_determine_majority_build_slave_architecture_id() { + { + printf 'SELECT' + printf ' COUNT(DISTINCT `ssh_log`.`id`) AS `count`,' + printf '`architectures`.`id`' + printf ' FROM `ssh_log`' + printf ' JOIN `architectures`' + printf ' ON `ssh_log`.`parameters`=CONCAT(`architectures`.`name`," ")' + printf ' WHERE `action`="get-assignment"' + printf ' AND `ssh_log`.`date`>ADDTIME(NOW(),"-1 00:00:00")' + printf ' GROUP BY `ssh_log`.`parameters`' + printf ' ORDER BY `count` DESC' + printf ' LIMIT 1' + } | \ + mysql_run_query | \ + cut -f2 +} |