<commit_before>/**
 * Features Controller
 */
angular.module('controllers').controller('featuresChange', ['$scope', '$state','$stateParams', '$http',
  function ($scope, $state, $stateParams, $http) {
    'use strict';

    /**
     * 初始化变量
     */
    $scope.transmitting = true;
    $scope.action = 'create';
    $scope._id = '';
    $scope.sort = 0;
    $scope.title = '';
    $scope.url = '';
    $scope.thumbnail = {};
    $scope.extensions = {};
    $scope.model = {};
    $scope.media = [];
    $scope.disabledExtMediaAdd = {};

    /**
     * 读取当前推荐模型和推荐
     */
    async.parallel({
      model: function (callback) {
        $http.get('/api/models/' + $stateParams.model)
          .then(function (res) {
            callback(null, res.data);
          }, function () {
            callback('读取推荐模型失败');
          });
      },
      feature: function (callback) {
        if (!$stateParams.feature) return callback();

        $http.get('/api/features/' + $stateParams.feature)
          .then(function (res) {
            callback(null, res.data);
          }, function () {
            callback('读取推荐失败');
          });
      }
    }, function (err, result) {
      if (err) {
        $scope.$emit('notification', {
          type: 'danger',
          message: err
        });

        return false;
      }

      var model = result.model;
      var feature = result.feature;

      $scope.model = model;

      if ($stateParams.feature) {
        $scope._id = feature._id;
        $scope.action = 'update';
        $scope.sort = feature.sort;
        $scope.title = feature.title;
        $scope.url = feature.url;
        $scope.extensions = feature.extensions;

        if (feature.thumbnail) {
          $scope.thumbnail._id = feature.thumbnail._id;
          $scope.thumbnail.uploadStatus = 'success';
          $scope.thumbnail.croppedImage = feature.thumbnail.src;
        }

        if (!_.isEmpty(feature.media)) {
          _.map(feature.media, function (medium) {
            var fileNameLast = _.get(medium.fileName.match(/^.+\.(\w+)$/), 1);

            var _medium = {
              file: null,
              fileName: medium.fileName,
              fileNameLast: fileNameLast,
              isImage: false,
              description: medium.description,<commit_msg>fix modifying features cannot upload pictures problem<commit_after>/**
 * Features Controller
 */
angular.module('controllers').controller('featuresChange', ['$scope', '$state','$stateParams', '$http',
  function ($scope, $state, $stateParams, $http) {
    'use strict';

    /**
     * 初始化变量
     */
    $scope.transmitting = true;
    $scope.action = 'create';
    $scope._id = '';
    $scope.sort = 0;
    $scope.title = '';
    $scope.url = '';
    $scope.thumbnail = {};
    $scope.extensions = {};
    $scope.model = {};
    $scope.media = [];
    $scope.disabledExtMediaAdd = {};

    /**
     * 读取当前推荐模型和推荐
     */
    async.parallel({
      model: function (callback) {
        $http.get('/api/models/' + $stateParams.model)
          .then(function (res) {
            callback(null, res.data);
          }, function () {
            callback('读取推荐模型失败');
          });
      },
      feature: function (callback) {
        if (!$stateParams.feature) return callback();

        $http.get('/api/features/' + $stateParams.feature)
          .then(function (res) {
            callback(null, res.data);
          }, function () {
            callback('读取推荐失败');
          });
      }
    }, function (err, result) {
      if (err) {
        $scope.$emit('notification', {
          type: 'danger',
          message: err
        });

        return false;
      }

      var model = result.model;
      var feature = result.feature;

      $scope.model = model;

      if ($stateParams.feature) {
        $scope._id = feature._id;
        $scope.action = 'update';
        $scope.sort = feature.sort;
        $scope.title = feature.title;
        $scope.url = feature.url;
        $scope.extensions = feature.extensions || {};

        if (feature.thumbnail) {
          $scope.thumbnail._id = feature.thumbnail._id;
          $scope.thumbnail.uploadStatus = 'success';
          $scope.thumbnail.croppedImage = feature.thumbnail.src;
        }

        if (!_.isEmpty(feature.media)) {
          _.map(feature.media, function (medium) {
            var fileNameLast = _.get(medium.fileName.match(/^.+\.(\w+)$/), 1);

            var _medium = {
              file: null,
              fileName: medium.fileName,
              fileNameLast: fileNameLast,
              isImage: false,
              description: medium.description,
{'fraction_non_alphanumeric': 0.1584628670120898, 'fraction_numerical': 0.0008635578583765112, 'mean_word_length': 1.8581122763726095, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6810472', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1397, 'n_words': 246}