<commit_before>(function() {
  'use strict';
  angular.module('civic.account')
    .controller('AccountNotificationsController', AccountNotificationsController);

  // @ngInject
  function AccountNotificationsController($scope,
                                          $state,
                                          $stateParams,
                                          $location,
                                          CurrentUser,
                                          Security,
                                          feed,
                                          _) {

    if(_.isUndefined($stateParams.category)) {
      $state.go('account.notifications', { category: 'all' })
    }
    var vm = $scope.vm = {};

    vm.countOptions= [10,25,50,100];
    vm.notifications = [];

    vm.unRead = Security.currentUser.unread_notifications;
    vm.category = $stateParams.category;

    vm.pageChanged = function() {
      $location.search({page: vm.page, count: vm.count, category: vm.category});
      fetch();
    };

    var fetch = function() {
      var request = {
        count: vm.count,
        page: vm.page,
        category: vm.category
      };

      if(!_.isEmpty(vm.filters.name)) {
        request['filter[name]'] = vm.filters.name;
      }
      if(!_.isEmpty(vm.filters.limit)) {
        request['filter[limit]'] = vm.filters.limit;
      }

      CurrentUser.getFeed(request)
    };

    vm.filterFields = [
      {
        key: 'name',
        type: 'input',
        templateOptions: {
          label: 'Find User',
          required: false
        },
        watcher: {
          listener: function() {
            fetch();
          }
        }
      },
      {
        key: 'limit',
        type: 'select',
        defaultValue: 'all_time',
        templateOptions: {
          label: 'Limit To',
          required: false,
          options: [
            // this_week, this_month, this_year, all_time
            {name: 'All time', value: 'all_time'},
            {name: 'This week', value: 'this_week'},
            {name: 'This month', value: 'this_month'},
            {name: 'This year', value: 'this_year'}
          ]
        },
        watcher: {
          listener: function() {
            fetch();
          }
        }
      }
    ];

    $scope.$watch(
      function() { return CurrentUser.data.feed.records},
      function(records){
        var meta = CurrentUser.data.feed._meta;

        vm.count = Number(meta.per_page);
        vm.page = Number(meta.current_page);
        vm.totalItems = Number(meta.total_count);
        vm.totalPages = Number(meta.total_pages);
        vm.category = $stateParams.category;

        vm.unread = meta.unread;
        vm.totalUnread = _.reduce(vm.unread, function(result, value, key) {
          return result + value;
        });

        angular.copy(CurrentUser.data.feed.records, vm.notifications);

        vm.categories = [{
          name: 'all',
          state: 'account.notifications({category:"all", page: vm.page, count: vm.count })',
          unread: _.reduce(vm.unread, function(res, val, key) {
            return res + val;
          })
        }];
<commit_msg>added 'show unlinkable' and 'show unread' checkboxes to notifications page<commit_after>(function() {
  'use strict';
  angular.module('civic.account')
    .controller('AccountNotificationsController', AccountNotificationsController);

  // @ngInject
  function AccountNotificationsController($scope,
                                          $state,
                                          $stateParams,
                                          $location,
                                          CurrentUser,
                                          Security,
                                          _) {

    if(_.isUndefined($stateParams.category)) {
      $state.go('account.notifications', { category: 'all' })
    }
    var vm = $scope.vm = {};

    vm.countOptions= [10,25,50,100];
    vm.notifications = [];

    vm.unRead = Security.currentUser.unread_notifications;
    vm.category = $stateParams.category;

    vm.filters = {
      showUnlinkable: true,
      showUnread: true
    }

    vm.pageChanged = function() {
      $location.search({page: vm.page, count: vm.count, category: vm.category});
      fetch();
    };

    var fetch = _.debounce(function() {
      var request = {
        count: vm.count,
        page: vm.page,
        category: vm.category
      };

      if(!_.isEmpty(vm.filters.name)) {
        request['filter[name]'] = vm.filters.name;
      }
      if(!_.isEmpty(vm.filters.limit)) {
        request['filter[limit]'] = vm.filters.limit;
      }

      request.show_unlinkable = vm.filters.showUnlinkable;
      request.show_unreadable = vm.filters.showUnread;

      CurrentUser.getFeed(request)
    }, 250);

    vm.filterFields = [
      {
        key: 'name',
        type: 'input',
        templateOptions: {
          label: 'Find User',
          required: false
        },
        watcher: {
          listener: function() {
            fetch();
          }
        }
      },
      {
        key: 'limit',
        type: 'select',
        defaultValue: 'all_time',
        templateOptions: {
          label: 'Limit To',
          required: false,
          options: [
            // this_week, this_month, this_year, all_time
            {name: 'All time', value: 'all_time'},
            {name: 'This week', value: 'this_week'},
            {name: 'This month', value: 'this_month'},
            {name: 'This year', value: 'this_year'}
          ]
        },
        watcher: {
          listener: function() {
            fetch();
          }
        }
      },
      {
        key: 'showUnlinkable',
        type: 'checkbox',
        defaultValue: 'true',
        templateOptions: {
          label: 'Show Unlinkable',
          required: false
        },
        watcher: {
          listener: function() {
            fetch();
          }
        }
      },
      {
        key: 'showUnread',
        type: 'checkbox',
        defaultValue: 'true',
        templateOptions: {
          label: 'Show Unreadable',
          required: false
        },
        watcher: {
          listener: function() {
            fetch();
          }
        }
      }
    ];

    $scope.$watch(
      function() { return CurrentUser.data.feed.records},
      function(records){
        var meta = CurrentUser.data.feed._meta;

        vm.count = Number(meta.per_page);
        vm.page = Number(meta.current_page);
        vm.totalItems = Number(meta.total_count);
        vm.totalPages = Number(meta.total_pages);
        vm.category = $stateParams.category;
        vm.showUnlinkable =

        vm.unread = meta.unread;
        vm.totalUnread = _.reduce(vm.unread, function(result, value, key) {
          return result + value;
        });

        angular.copy(CurrentUser.data.feed.records, vm.notifications);

        vm.categories = [{
          name: 'all',
          state: 'account.notifications({category:"all", page: vm.page, count: vm.count })',
          unread: _.reduce(vm.unread, function(res, val, key) {
            return res + val;
          })
        }];

{'fraction_non_alphanumeric': 0.12920255626562935, 'fraction_numerical': 0.002917477076965824, 'mean_word_length': 1.5321843123461132, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '827458', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1944, 'n_words': 369}