<commit_before>const editCtrl = require('./profile-edit.ctrl.js');
const angular = require('angular');

module.exports = function($scope, $routeParams, io, $mdMedia, $mdDialog, errorHandler) {
  this.data = this.data || {};
  this.data.name = this.data.name || $routeParams.username;
  this.errorStatusCode = null;

  this.fetch = () => Promise.all([this.fetchInfo, this.fetchBoxes]);

  this.fetchInfo = () => {
    return io.socket.getAsync(`/api/v1/user/${this.data.name}`).then(res => {
      Object.assign(this.data, res);
    }).catch(err => {
      this.errorStatusCode = err.statusCode;
    }).then(() => $scope.$apply());
  };

  this.fetchBoxes = () => {
    return io.socket.getAsync(`/api/v1/user/${this.data.name}/boxes`).then(res => {
      this.data.boxes = res;
    }).catch(errorHandler).then(() => $scope.$apply());
  };

  this.edit = event => {
    const useFullScreen = ($mdMedia('sm') || $mdMedia('xs'))  && $scope.customFullscreen;
    $scope.$watch(function() {
      return $mdMedia('xs') || $mdMedia('sm');
    }, function(wantsFullScreen) {
      $scope.customFullscreen = (wantsFullScreen === true);
    });
    return Promise.resolve($mdDialog.show({
      locals: {data: this.data},
      bindToController: true,
      controller: ['$mdDialog', editCtrl],
      controllerAs: 'dialog',
      templateUrl: 'profile/profile-edit.view.html',
      parent: angular.element(document.body),
      targetEvent: event,
      clickOutsideToClose: true,
      fullscreen: useFullScreen
    }).then((editedData) => {
      return io.socket.patchAsync('/api/v1/me', editedData).then(() => {
        Object.assign(this.data, editedData);
        $scope.$apply();
      });
    })).catch(errorHandler);
  };
};<commit_msg>Use prototype functions in profile.ctrl.js<commit_after>const editCtrl = require('./profile-edit.ctrl.js');
const angular = require('angular');

module.exports = class Profile {
  constructor ($scope, $routeParams, io, $mdMedia, $mdDialog, errorHandler) {
    this.$scope = $scope;
    this.$routeParams = $routeParams;
    this.io = io;
    this.$mdMedia = $mdMedia;
    this.$mdDialog = $mdDialog;
    this.errorHandler = errorHandler;
    this.data = this.data || {};
    this.data.name = this.data.name || $routeParams.username;
    this.errorStatusCode = null;
  }
  fetch () {
    return Promise.all([this.fetchInfo(), this.fetchBoxes()]);
  }
  fetchInfo () {
    return this.io.socket.getAsync(`/api/v1/user/${this.data.name}`).then(res => {
      Object.assign(this.data, res);
    }).catch(err => {
      this.errorStatusCode = err.statusCode;
    }).catch(this.errorHandler).then(() => this.$scope.$apply());
  }
  fetchBoxes () {
    return this.io.socket.getAsync(`/api/v1/user/${this.data.name}/boxes`).then(res => {
      this.data.boxes = res;
    }).catch(this.errorHandler).then(() => this.$scope.$apply());
  }
  edit (event) {
    const useFullScreen
      = (this.$mdMedia('sm') || this.$mdMedia('xs')) && this.$scope.customFullscreen;
    this.$scope.$watch(() => {
      return this.$mdMedia('xs') || this.$mdMedia('sm');
    }, wantsFullScreen => {
      this.$scope.customFullscreen = (wantsFullScreen === true);
    });
    return Promise.resolve(this.$mdDialog.show({
      locals: {data: this.data},
      bindToController: true,
      controller: ['$mdDialog', editCtrl],
      controllerAs: 'dialog',
      templateUrl: 'profile/profile-edit.view.html',
      parent: angular.element(document.body),
      targetEvent: event,
      clickOutsideToClose: true,
      fullscreen: useFullScreen
    }).then((editedData) => {
      return this.io.socket.patchAsync('/api/v1/me', editedData).then(() => {
        Object.assign(this.data, editedData);
        this.$scope.$apply();
      });
    })).catch(this.errorHandler);
  }
};
{'fraction_non_alphanumeric': 0.1911415765884524, 'fraction_numerical': 0.0015818613234906407, 'mean_word_length': 3.2918552036199094, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '1856762', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1205, 'n_words': 190}