<commit_before>app.controller('CardsController', ['$scope', '$window', '$routeParams', 'Database', '$controller',
  function ($scope, $window, $routeParams, Database, $controller) {
    'use strict';

    $controller('EditController', {$scope: $scope});

    $scope.save = function (redirect) {
      $scope.entity.to = $scope.entity.to / 1000;
      var params = {
        entity: $scope.entity,
        coll: 'cards',
        type: $routeParams.action
      };
      $scope.err = {};
      Database.saveEntity(params).then(function (res) {
        if (redirect) {
          $window.location = baseUrl + '/admin/' + $routeParams.collection;
        }
      }, function (err) {
        $scope.err = err;

      });
    };

    $scope.isStatusDisabled = function (status) {
      var curr_card_status = $scope.card_status.toLowerCase();
      if (status === undefined)
        return true;
      if ($scope.card_status === undefined)
        return false;
      status = status.toLowerCase();
      // idle -> (active optional) -> [expired,stolen,disqualified,used]
      // don't allow going backwards
      if (curr_card_status === "idle")
        return false;
      if (curr_card_status === "active" && status === "idle")<commit_msg>fixed card save (calls cards API)<commit_after>app.controller('CardsController', ['$scope', '$window', '$routeParams', 'Database', '$controller', '$http',
  function ($scope, $window, $routeParams, Database, $controller, $http) {
    'use strict';

    $controller('EditController', {$scope: $scope});

    $scope.save = function (redirect) {
      $scope.entity.to = $scope.entity.to / 1000;
      $scope.err = {};
      //Database.saveEntity(params).then(function (res) {
      var postData = {
        method: ($scope.action === "new" ? 'create' : 'update')
      };
      var entData = {
        status: $scope.entity.status,
        batch_number: $scope.entity.batch_number,
        serial_number: $scope.entity.serial_number,
        charging_plan_name: $scope.entity.charging_plan_name,
        service_provider: $scope.entity.service_provider,
        to: $scope.entity.to
      };
      if ($scope.action === "new") postData.cards = [JSON.stringify(entData)];
      else {
        postData.query = JSON.stringify({
          serial_number: $scope.entity.serial_number,
          batch_number: $scope.entity.batch_number
        });
        postData.update = JSON.stringify(entData);
      }
      $http.post(baseUrl + '/api/cards', postData).then(function (res) {
        if (redirect) {
          $window.location = baseUrl + '/admin/' + $routeParams.collection;
        }
      }, function (err) {
        $scope.err = err;

      });
    };

    $scope.isStatusDisabled = function (status) {
      var curr_card_status = $scope.card_status.toLowerCase();
      if (status === undefined)
        return true;
      if ($scope.card_status === undefined)
        return false;
      status = status.toLowerCase();
      // idle -> (active optional) -> [expired,stolen,disqualified,used]
      // don't allow going backwards
      if (curr_card_status === "idle")
        return false;
      if (curr_card_status === "active" && status === "idle")
{'fraction_non_alphanumeric': 0.1570040739580069, 'fraction_numerical': 0.0025070510811657787, 'mean_word_length': 2.652173913043478, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7307458', 'n_tokens_mistral': 941, 'n_tokens_neox': 934, 'n_words': 197}