<commit_before>var opsAppModule = angular.module('opsApp',[]);

opsAppModule.factory('OpsApi', function ($http) {
    var api = {};
		//munge the data to show school name and value
    api.getSchools = function () {
        return $http.get("/schools" , {cache: true})
    };
    api.getSchool = function (schoolId) {
			console.log('school id is '+ schoolId)
        return $http.get("/school/" + schoolId , {cache: true})
    };
    api.getCounties = function () {
        return $http.get("/schools" )
    };
    api.getDistricts = function () {
        return $http.get("/districts")
    };
    api.getDistrict = function (districtID) {
        return $http.get("/district/" + districtID )
    };
    return api;
});

opsAppModule.controller('OpsCtrl', function ($scope, OpsApi) {


  $scope.updateCards = function(){
    OpsApi.getSchool($scope.schoolInView).success(function (data){
      $scope.cardName = data.School.Name;
      var schoolId = data.School.Id;
      var enrollmentLevel = data.EnrollmentByYear[data.EnrollmentByYear.length - 1];
      $scope.totalEnrollment = enrollmentLevel.Students;
      $scope.totalTeachers = enrollmentLevel.Teachers;
      $scope.drawStackedBar(schoolId, "school");
    });
    $scope.totalSchools = "1,367";
    $scope.cardYear = "2012-2013";
  }
  $scope.districtChanged = function() {
    var districtsInSchool = $scope.allDistricts.filter(function(i) {
      return i.Id == $scope.currentDistrict;
    })[0];
    $scope.schoolsForDistrict = districtsInSchool.Schools;
    $scope.drawStackedBar($scope.currentDistrict, "district");
    OpsApi.getDistrict($scope.currentDistrict).success(function(data) {
      $scope.cardName = data.District.Name;
      var enrollmentLevel = data.EnrollmentsByYear[data.EnrollmentsByYear.length - 1];
      $scope.totalEnrollment = enrollmentLevel.Students;
      $scope.totalTeachers = enrollmentLevel.Teachers;
    });
  };

  $scope.updateSchoolCharts = function(){
    $scope.updateCards();
  }

	 	$scope.yearAry=['2002/2003','2003/2004','2004/2005','2005/2006','2006/2007','2007/2008','2008/2009','2009/2010',
	 	'2010/2011','2011/2012','2012/2013'];

    $scope.schoolInView = 280001005;
	 	$scope.schoolId = 280001005; //fixme get rid of this
	 	//this is the one to use for UI
    $scope.drawStackedBar = function(id, type){
      if (type == "school") {
        OpsApi.getSchool(id).success(function (data){
          $scope.createStackedBar($scope.mungeDataForStackedBar(data));
        });
      } else {
        OpsApi.getDistrict(id).success(function(data) {
          $scope.createStackedBar($scope.mungeDistrictData(data));
        });
      }
    }
			 /* reference 
			  [{"Year":"1","Grade 09":"591","Grade 10":"485","Grade 11":"453","Grade 12":"430"},
				  {"Year":"1","Grade 09":"591","Grade 10":"485","Grade 11":"453","Grade 12":"430"}
					]<commit_msg>Remove console log and fulfilling alex's wishes<commit_after>var opsAppModule = angular.module('opsApp',[]);

opsAppModule.factory('OpsApi', function ($http) {
    var api = {};
		//munge the data to show school name and value
    api.getSchools = function () {
        return $http.get("/schools" , {cache: true})
    };
    api.getSchool = function (schoolId) {
        return $http.get("/school/" + schoolId , {cache: true})
    };
    api.getCounties = function () {
        return $http.get("/schools" )
    };
    api.getDistricts = function () {
        return $http.get("/districts")
    };
    api.getDistrict = function (districtID) {
        return $http.get("/district/" + districtID )
    };
    return api;
});

opsAppModule.controller('OpsCtrl', function ($scope, OpsApi) {


  $scope.updateCards = function(){
    OpsApi.getSchool($scope.schoolInView).success(function (data){
      $scope.cardName = data.School.Name;
      var schoolId = data.School.Id;
      var enrollmentLevel = data.EnrollmentByYear[data.EnrollmentByYear.length - 1];
      $scope.totalEnrollment = enrollmentLevel.Students;
      $scope.totalTeachers = enrollmentLevel.Teachers;
      $scope.drawStackedBar(schoolId, "school");
    });
    $scope.totalSchools = "1,367";
    $scope.cardYear = "2012-2013";
  }
  $scope.districtChanged = function() {
    var districtsInSchool = $scope.allDistricts.filter(function(i) {
      return i.Id == $scope.currentDistrict;
    })[0];
    $scope.schoolsForDistrict = districtsInSchool.Schools;
    $scope.drawStackedBar($scope.currentDistrict, "district");
    OpsApi.getDistrict($scope.currentDistrict).success(function(data) {
      $scope.cardName = data.District.Name;
      var enrollmentLevel = data.EnrollmentsByYear[data.EnrollmentsByYear.length - 1];
      $scope.totalEnrollment = enrollmentLevel.Students;
      $scope.totalTeachers = enrollmentLevel.Teachers;
    });
  };

  $scope.updateSchoolCharts = function(){
    if ($scope.schoolInView) {
      $scope.updateCards();
    } else {
      $scope.districtChanged();
    }
  }

	 	$scope.yearAry=['2002/2003','2003/2004','2004/2005','2005/2006','2006/2007','2007/2008','2008/2009','2009/2010',
	 	'2010/2011','2011/2012','2012/2013'];

    $scope.schoolInView = 280001005;
	 	$scope.schoolId = 280001005; //fixme get rid of this
	 	//this is the one to use for UI
    $scope.drawStackedBar = function(id, type){
      if (type == "school") {
        OpsApi.getSchool(id).success(function (data){
          $scope.createStackedBar($scope.mungeDataForStackedBar(data));
        });
      } else {
        OpsApi.getDistrict(id).success(function(data) {
          $scope.createStackedBar($scope.mungeDistrictData(data));
        });
      }
    }
			 /* reference 
			  [{"Year":"1","Grade 09":"591","Grade 10":"485","Grade 11":"453","Grade 12":"430"},
				  {"Year":"1","Grade 09":"591","Grade 10":"485","Grade 11":"453","Grade 12":"430"}
					]
{'fraction_non_alphanumeric': 0.16586206896551725, 'fraction_numerical': 0.05620689655172414, 'mean_word_length': 3.355105105105105, 'pattern_counts': {'":': 20, '<': 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': '2051873', 'n_tokens_mistral': 2198, 'n_tokens_neox': 1805, 'n_words': 300}