<commit_before>angular.module('ot.view.home', [
    'ui.router',
    'ot.service.structure',
    'ot.service.core',
    'ot.service.user',
    'ot.service.graphql',
    'ot.service.label'
])
    .config(function ($stateProvider) {
        $stateProvider.state('home', {
            url: '/home',
            templateUrl: 'app/view/view.home.tpl.html',
            controller: 'HomeCtrl'
        });
    })
    .controller('HomeCtrl', function ($rootScope, $location, $log, $scope, $http, ot, otGraphqlService, otStructureService, otNotificationService, otUserService, otLabelService) {
        const search = $location.search();
        const code = search.code;
        const url = search.url;
        $rootScope.view = {
            // Title
            title: 'Home',
            // Commands
            commands: []
        };

        // Preloading filter mode
        $scope.preloadingLabelFilter = true;

        // No initial filter
        $scope.projectFilter = {
            name: '',
            label: undefined
        };

        // Maximum number of branches to return per project favourite
        const maxBranches = 5;

        // Loading the project list
        function loadProjects() {
            $scope.loadingProjects = true;
            otGraphqlService.pageGraphQLCall(`{
              userRootActions {
                projectCreate
              }
              labels {
                id
                category
                name
                description
                color
                foregroundColor
                computedBy {
                    id
                    name
                }
                links {
                    _update
                    _delete
                }
              }
              favouriteBranches: branches(favourite: true) {
                project {
                  name
                  links {
                    _page
                  }
                }
                id
                name
                disabled
                type
                decorations {
                  ...decorationContent
                }
                creation {
                  time
                }
                links {
                  _page
                  _enable
                  _disable
                  _delete
                  _unfavourite
                  _favourite
                }
                latestBuild: builds(count: 1) {
                  id
                  name
                  creation {
                      time
                  }
                }
                promotionLevels {
                  id
                  name
                  image
                  _image
                  promotionRuns(first: 1) {
                    build {
                      id
                      name
                    }
                  }
                }
              }
              projects {
                id
                name
                labels {
                  id
                  category
                  name
                  description
                  color
                  foregroundColor
                  computedBy {
                    id
                    name
                  }
                }
                links {
                  _favourite
                  _unfavourite
                }
                decorations {
                  ...decorationContent
                }
              }
              projectFavourites: projects(favourites: true) {
                id
                name
                disabled
                decorations {
                  ...decorationContent
                }
                links {
                  _unfavourite
                }
                branches(useModel: true, count: ${maxBranches}) {
                  id
                  name
                  type
                  disabled
                  decorations {
                    ...decorationContent
                  }
                  latestPromotions: builds(lastPromotions: true, count: 1) {
                    id
                    name
                    promotionRuns {
                      promotionLevel {
                        id
                        name
                        image
                        _image
                      }
                    }
                  }
                  latestBuild: builds(count: 1) {
                    id
                    name
                  }
                }
              }
            }
            
            fragment decorationContent on Decoration {
              decorationType
              error
              data
              feature {
                id
              }
            }
            `).then(function (data) {

                $scope.projectsData = data;
                $scope.projectFavourites = data.projectFavourites;
                $scope.favouriteBranches = data.favouriteBranches;

                preloadLabelFilter();

                // All branches disabled status computation
                $scope.projectFavourites.forEach(function (projectFavourite) {
                    projectFavourite.allBranchesDisabled = projectFavourite.branches.length > 0 &&
                        projectFavourite.branches.every(function (branch) {
                            return branch.disabled || branch.type === 'TEMPLATE_DEFINITION';
                        });
                });

                // Commands
                $rootScope.view.commands = [
                    {
                        id: 'createProject',
                        name: 'Create project',
                        cls: 'ot-command-project-new',
                        condition: function () {
                            return data.userRootActions.projectCreate;
                        },
                        action: $scope.createProject<commit_msg>#858 Using the settings to make the number of displayed branch globally configurable<commit_after>angular.module('ot.view.home', [
    'ui.router',
    'ot.service.structure',
    'ot.service.core',
    'ot.service.user',
    'ot.service.graphql',
    'ot.service.label'
])
    .config(function ($stateProvider) {
        $stateProvider.state('home', {
            url: '/home',
            templateUrl: 'app/view/view.home.tpl.html',
            controller: 'HomeCtrl'
        });
    })
    .controller('HomeCtrl', function ($rootScope, $location, $log, $scope, $http, ot, otGraphqlService, otStructureService, otNotificationService, otUserService, otLabelService) {
        const search = $location.search();
        const code = search.code;
        const url = search.url;
        $rootScope.view = {
            // Title
            title: 'Home',
            // Commands
            commands: []
        };

        // Preloading filter mode
        $scope.preloadingLabelFilter = true;

        // No initial filter
        $scope.projectFilter = {
            name: '',
            label: undefined
        };

        // Maximum number of branches to return per project favourite
        const maxBranches = 5;

        // Loading the project list
        function loadProjects() {
            $scope.loadingProjects = true;
            // We start collecting some global settings
            otGraphqlService.pageGraphQLCall(`{
                settings {
                    homePage {
                        maxBranches
                        maxProjects
                    }
                }
                entityCounts {
                    projects
                }
            }`).then(global => {
                // Storing the data
                $scope.maxBranches = global.settings.homePage.maxBranches;
                $scope.maxProjects = global.settings.homePage.maxProjects;
                $scope.projectCount = global.entityCounts.projects;
                // Actual call
                return otGraphqlService.pageGraphQLCall(`{
                  userRootActions {
                    projectCreate
                  }
                  labels {
                    id
                    category
                    name
                    description
                    color
                    foregroundColor
                    computedBy {
                        id
                        name
                    }
                    links {
                        _update
                        _delete
                    }
                  }
                  favouriteBranches: branches(favourite: true) {
                    project {
                      name
                      links {
                        _page
                      }
                    }
                    id
                    name
                    disabled
                    type
                    decorations {
                      ...decorationContent
                    }
                    creation {
                      time
                    }
                    links {
                      _page
                      _enable
                      _disable
                      _delete
                      _unfavourite
                      _favourite
                    }
                    latestBuild: builds(count: 1) {
                      id
                      name
                      creation {
                          time
                      }
                    }
                    promotionLevels {
                      id
                      name
                      image
                      _image
                      promotionRuns(first: 1) {
                        build {
                          id
                          name
                        }
                      }
                    }
                  }
                  projects {
                    id
                    name
                    labels {
                      id
                      category
                      name
                      description
                      color
                      foregroundColor
                      computedBy {
                        id
                        name
                      }
                    }
                    links {
                      _favourite
                      _unfavourite
                    }
                    decorations {
                      ...decorationContent
                    }
                  }
                  projectFavourites: projects(favourites: true) {
                    id
                    name
                    disabled
                    decorations {
                      ...decorationContent
                    }
                    links {
                      _unfavourite
                    }
                    branches(useModel: true, count: ${$scope.maxBranches}) {
                      id
                      name
                      type
                      disabled
                      decorations {
                        ...decorationContent
                      }
                      latestPromotions: builds(lastPromotions: true, count: 1) {
                        id
                        name
                        promotionRuns {
                          promotionLevel {
                            id
                            name
                            image
                            _image
                          }
                        }
                      }
                      latestBuild: builds(count: 1) {
                        id
                        name
                      }
                    }
                  }
                }
                
                fragment decorationContent on Decoration {
                  decorationType
                  error
                  data
                  feature {
                    id
                  }
                }
                `);
            }).then(function (data) {

                $scope.projectsData = data;
                $scope.projectFavourites = data.projectFavourites;
                $scope.favouriteBranches = data.favouriteBranches;

                preloadLabelFilter();

                // All branches disabled status computation
                $scope.projectFavourites.forEach(function (projectFavourite) {
                    projectFavourite.allBranchesDisabled = projectFavourite.branches.length > 0 &&
                        projectFavourite.branches.every(function (branch) {
                            return branch.disabled || branch.type === 'TEMPLATE_DEFINITION';
                        });
                });

                // Commands
                $rootScope.view.commands = [
                    {
                        id: 'createProject',
                        name: 'Create project',
                        cls: 'ot-command-project-new',
                        condition: function () {
                            return data.userRootActions.projectCreate;
                        },
                        action: $scope.createProject
{'fraction_non_alphanumeric': 0.05962920923193341, 'fraction_numerical': 0.0011350737797956867, 'mean_word_length': 0.6809972017298397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4250630', 'n_tokens_mistral': 2855, 'n_tokens_neox': 2498, 'n_words': 509}