<commit_before>(function () {
  'use strict';

  angular
    .module('brew_journal.recipies.controllers')
    .controller('RecipeController', RecipeController);

  RecipeController.$inject = ['$scope', '$filter', 'Recipe'];

  /**
  * @namespace RecipeController
  */
  function RecipeController($scope, $filter, Recipe) {
    var ctrl = this;

    ctrl.onRecipeSelect = onRecipeSelect;
    ctrl.openBrewDatepicker = openBrewDatepicker;
    ctrl.addHop = addHop;
    ctrl.removeHop = removeHop;
    ctrl.addMalt = addMalt;
    ctrl.removeMalt = removeMalt;
    ctrl.clearForm = clearForm;
    ctrl.deleteRecipe = deleteRecipe;
    ctrl.save = save;

    // Setup default loading recipe
    ctrl.recipes = [{id:null, name:'Loading...'}];
    ctrl.hops = [];
    ctrl.malts = [];
    ctrl.recipe_id = null;

    ctrl.datePickerIsOpen = false;
    ctrl.last_brew_date = new Date();

    // Activate the page
    activate();

    /**
     * @name activate
     * @desc activate the page
     * @param none
     * @memberOf brew_journal.recipies.controllers.RecipeController
     */
    function activate() {
      Recipe.listRecipes().then(loadRecipeDropdown);
    }

    /**
     * @name deleteRecipe
     * @desc Delete the selected recipe from the dropdown
     * @param {int} The id of the recipe to delete
     * @memberOf brew_journal.recipies.controllers.RecipeController
     */ 
    function deleteRecipe(recipe_id) {
      Recipe.deleteRecipe(recipe_id).then(onDeleteRecipeResponse);
    }

    /**
     * @name onDeleteRecipeResponse
     * @desc Handle the response message from the delete action
     * @param {Object} The response object.
     * @memberOf brew_journal.recipies.controllers.RecipeController
     */
    function onDeleteRecipeResponse(response) {<commit_msg>Added a validation on recipe page load to ensure that there is a current user session<commit_after>(function () {
  'use strict';

  angular
    .module('brew_journal.recipies.controllers')
    .controller('RecipeController', RecipeController);

  RecipeController.$inject = ['$scope', '$filter', '$location', 'Recipe', 'Authentication'];

  /**
  * @namespace RecipeController
  */
  function RecipeController($scope, $filter, $location, Recipe, Authentication) {
    var ctrl = this;

    ctrl.onRecipeSelect = onRecipeSelect;
    ctrl.openBrewDatepicker = openBrewDatepicker;
    ctrl.addHop = addHop;
    ctrl.removeHop = removeHop;
    ctrl.addMalt = addMalt;
    ctrl.removeMalt = removeMalt;
    ctrl.clearForm = clearForm;
    ctrl.deleteRecipe = deleteRecipe;
    ctrl.save = save;

    // Setup default loading recipe
    ctrl.recipes = [{id:null, name:'Loading...'}];
    ctrl.hops = [];
    ctrl.malts = [];
    ctrl.recipe_id = null;

    ctrl.datePickerIsOpen = false;
    ctrl.last_brew_date = new Date();

    // Activate the page
    activate();

    /**
     * @name activate
     * @desc activate the page
     * @param none
     * @memberOf brew_journal.recipies.controllers.RecipeController
     */
    function activate() {
      // Ensure there is an active user session
      if(!Authentication.isAuthenticated()) {
        $location.url('/view/login');
      } else {
        Recipe.listRecipes().then(loadRecipeDropdown);
      }
    }

    /**
     * @name deleteRecipe
     * @desc Delete the selected recipe from the dropdown
     * @param {int} The id of the recipe to delete
     * @memberOf brew_journal.recipies.controllers.RecipeController
     */ 
    function deleteRecipe(recipe_id) {
      Recipe.deleteRecipe(recipe_id).then(onDeleteRecipeResponse);
    }

    /**
     * @name onDeleteRecipeResponse
     * @desc Handle the response message from the delete action
     * @param {Object} The response object.
     * @memberOf brew_journal.recipies.controllers.RecipeController
     */
    function onDeleteRecipeResponse(response) {
{'fraction_non_alphanumeric': 0.1138780804150454, 'fraction_numerical': 0.0, 'mean_word_length': 3.0292580982236155, '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': '4440929', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1139, 'n_words': 259}