<commit_before>'use strict';

// Shop fruits controller
angular.module('shop-fruits').controller('ShopFruitsController', ['$scope', '$stateParams', '$location', 'Authentication', 'ShopFruits','$http',
	function($scope, $stateParams, $location, Authentication, ShopFruits, $http) {
		$scope.authentication = Authentication;

		// Create new Shop fruit
		$scope.create = function() {
			// Create new Shop fruit object
			var shopFruit = new ShopFruits ({
				name: this.name
			});

			// Redirect after save
			shopFruit.$save(function(response) {
				$location.path('shop-fruits/' + response._id);

				// Clear form fields
				$scope.name = '';
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};
    
    $scope.removeSpecific = function(shopFruit) {
      if(confirm('Please Explain about App before Deleting')) {
        if (shopFruit) {
          shopFruit.$remove();
          for (var i in $scope.shopFruits) {
            if ($scope.shopFruits [i] === shopFruit) {
              $scope.shopFruits.splice(i, 1);
            }
          }
        } else {

          //$scope.shopFruit.$remove(function () {
          //  $location.path('shop-groceries');
          //});
          $http({
            method: 'PUT',
            data: shopFruit,
            url: 'http://getmeher.com:3000/shop-fruits/'+shopFruit._id
          }).then(function successCallback(response) {
            console.log(response)
            alert("done")
          }, function errorCallback(response) {
            console.log(response)
            alert("error" + response);
          });

        }
      }
    };


    // Remove existing Shop fruit
		$scope.remove = function(shopFruit) {
			if ( shopFruit ) { 
				shopFruit.$remove();

				for (var i in $scope.shopFruits) {
					if ($scope.shopFruits [i] === shopFruit) {
						$scope.shopFruits.splice(i, 1);
					}
				}
			} else {
				$scope.shopFruit.$remove(function() {
					$location.path('shop-fruits');
				});
			}
		};

		// Update existing Shop fruit
		$scope.update = function() {
			var shopFruit = $scope.shopFruit;

			shopFruit.$update(function() {
				$location.path('shop-fruits/' + shopFruit._id);
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Find a list of Shop fruits
		$scope.find = function() {
			$scope.shopFruits = ShopFruits.query();
		};

    $scope.findNearby = function() {
      //$scope.shopFruits = shopFruits.query();
      $scope.pageNumber = 0;
      console.log($scope.areaLocation);
      if ($scope.areaLocation) {
        $scope.areaLng = $scope.areaLocation.geometry.location.lng();
        $scope.areaLat = $scope.areaLocation.geometry.location.lat();
      }
      else{
        $scope.areaLng = 71;
        $scope.areaLat = 19;
      }
      $scope.pageNumber = 1;
      console.log($scope.pageNumber);
      $http.get('http://getmeher.com:3000/shop-fruits/near/' + $scope.areaLng + '/' + $scope.areaLat + '/' + $scope.pageNumber).
          then(function (response) {
            $scope.shopFruits = (response.data);
            $scope.$broadcast('scroll.infiniteScrollComplete');
          }, function (response) {
            // called asynchronously if an error occurs
            // or server returns response with an error status.
          });
    };

    $scope.loadmore = function() {
      //$scope.shopFruits = shopFruits.query();
      console.log($scope.areaLocation);
      if ($scope.areaLocation) {
        $scope.areaLng = $scope.areaLocation.geometry.location.lng();
        $scope.areaLat = $scope.areaLocation.geometry.location.lat();
      }
      else{
        $scope.areaLng = 71;
        $scope.areaLat = 19;
      }
      $scope.pageNumber = $scope.pageNumber + 1;
      console.log($scope.pageNumber);
      $http.get('http://getmeher.com:3000/shop-fruits/near/' + $scope.areaLng + '/' + $scope.areaLat + '/' + $scope.pageNumber).
          then(function (response) {
            $scope.shopFruits = (response.data);
            $scope.$broadcast('scroll.infiniteScrollComplete');
          }, function (response) {
            // called asynchronously if an error occurs
            // or server returns response with an error status.
          });
    };


    $scope.updateSpecific = function(shopFruitData) {
      var shopFruit = shopFruitData;
      console.log(shopFruit);
      $http({
        method: 'PUT',
        data: shopFruitData,
        url: 'http://getmeher.com:3000/shop-fruits/'+shopFruitData._id
      }).then(function successCallback(response) {
        console.log(response)
        alert("done")
      }, function errorCallback(response) {
        console.log(response)
        alert("error" + response);
      });


      //shopFruit.pushUpdates(function() {
      //  //$location.path('shop-groceries/' + shopFruit._id);
      //  alert("Saved!");
      //}, function(errorResponse) {
      //  $scope.error = errorResponse.data.message;
      //});

    };

    // Find existing Shop grocery
    $scope.findSpecific = function(shopFruitId) {
      alert("Fetching");
      $scope.shopFruit = shopFruits.get({
        shopFruitId: shopFruitId
      });
    };

    // Find existing Shop fruit
		$scope.findOne = function() {
			$scope.shopFruit = ShopFruits.get({ 
				shopFruitId: $stateParams.shopFruitId
			});
		};
	}
]);
<commit_msg>edit user auth<commit_after>'use strict';

// Shop fruits controller
angular.module('shop-fruits').controller('ShopFruitsController', ['$scope', '$stateParams', '$location', 'Authentication', 'ShopFruits','$http',
	function($scope, $stateParams, $location, Authentication, ShopFruits, $http) {
		$scope.authentication = Authentication;

		// Create new Shop fruit
		$scope.create = function() {
			// Create new Shop fruit object
			var shopFruit = new ShopFruits ({
				name: this.name
			});

			// Redirect after save
			shopFruit.$save(function(response) {
				$location.path('shop-fruits/' + response._id);

				// Clear form fields
				$scope.name = '';
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};



    $scope.removeSpecific = function(shopFruit) {

      //$scope.shopFruit.$remove(function () {
      //  $location.path('shop-groceries');
      //});
      $http({
        method: 'PUT',
        data: shopFruit,
        url: 'http://getmeher.com:3000/shop-fruits/'+shopFruit._id
      }).then(function successCallback(response) {
        console.log(response)
        alert("done");
        for (var i in $scope.shopFruits) {
          if ($scope.shopFruits [i] === shopFruit) {
            $scope.shopFruits.splice(i, 1);
          }
        }
      }, function errorCallback(response) {
        console.log(response)
        alert("error" + response);
      });

    }


    $scope.removeSpecific = function(shopFruit) {
      if(confirm('Please Explain about App before Deleting')) {
        if (shopFruit) {
          shopFruit.$remove();
          for (var i in $scope.shopFruits) {
            if ($scope.shopFruits [i] === shopFruit) {
              $scope.shopFruits.splice(i, 1);
            }
          }
        } else {
          $scope.shopFruit.$remove(function () {
            $location.path('shop-groceries');
          });
        }
      }
    };


    // Remove existing Shop fruit
		$scope.remove = function(shopFruit) {
			if ( shopFruit ) { 
				shopFruit.$remove();

				for (var i in $scope.shopFruits) {
					if ($scope.shopFruits [i] === shopFruit) {
						$scope.shopFruits.splice(i, 1);
					}
				}
			} else {
				$scope.shopFruit.$remove(function() {
					$location.path('shop-fruits');
				});
			}
		};

		// Update existing Shop fruit
		$scope.update = function() {
			var shopFruit = $scope.shopFruit;

			shopFruit.$update(function() {
				$location.path('shop-fruits/' + shopFruit._id);
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		// Find a list of Shop fruits
		$scope.find = function() {
			$scope.shopFruits = ShopFruits.query();
		};

    $scope.findNearby = function() {
      //$scope.shopFruits = shopFruits.query();
      $scope.pageNumber = 0;
      console.log($scope.areaLocation);
      if ($scope.areaLocation) {
        $scope.areaLng = $scope.areaLocation.geometry.location.lng();
        $scope.areaLat = $scope.areaLocation.geometry.location.lat();
      }
      else{
        $scope.areaLng = 71;
        $scope.areaLat = 19;
      }
      $scope.pageNumber = 1;
      console.log($scope.pageNumber);
      $http.get('http://getmeher.com:3000/shop-fruits/near/' + $scope.areaLng + '/' + $scope.areaLat + '/' + $scope.pageNumber).
          then(function (response) {
            $scope.shopFruits = (response.data);
            $scope.$broadcast('scroll.infiniteScrollComplete');
          }, function (response) {
            // called asynchronously if an error occurs
            // or server returns response with an error status.
          });
    };

    $scope.loadmore = function() {
      //$scope.shopFruits = shopFruits.query();
      console.log($scope.areaLocation);
      if ($scope.areaLocation) {
        $scope.areaLng = $scope.areaLocation.geometry.location.lng();
        $scope.areaLat = $scope.areaLocation.geometry.location.lat();
      }
      else{
        $scope.areaLng = 71;
        $scope.areaLat = 19;
      }
      $scope.pageNumber = $scope.pageNumber + 1;
      console.log($scope.pageNumber);
      $http.get('http://getmeher.com:3000/shop-fruits/near/' + $scope.areaLng + '/' + $scope.areaLat + '/' + $scope.pageNumber).
          then(function (response) {
            $scope.shopFruits = (response.data);
            $scope.$broadcast('scroll.infiniteScrollComplete');
          }, function (response) {
            // called asynchronously if an error occurs
            // or server returns response with an error status.
          });
    };


    $scope.updateSpecific = function(shopFruitData) {
      var shopFruit = shopFruitData;
      console.log(shopFruit);
      $http({
        method: 'PUT',
        data: shopFruitData,
        url: 'http://getmeher.com:3000/shop-fruits/'+shopFruitData._id
      }).then(function successCallback(response) {
        console.log(response)
        alert("done")
      }, function errorCallback(response) {
        console.log(response)
        alert("error" + response);
      });


      //shopFruit.pushUpdates(function() {
      //  //$location.path('shop-groceries/' + shopFruit._id);
      //  alert("Saved!");
      //}, function(errorResponse) {
      //  $scope.error = errorResponse.data.message;
      //});

    };

    // Find existing Shop grocery
    $scope.findSpecific = function(shopFruitId) {
      alert("Fetching");
      $scope.shopFruit = shopFruits.get({
        shopFruitId: shopFruitId
      });
    };

    // Find existing Shop fruit
		$scope.findOne = function() {
			$scope.shopFruit = ShopFruits.get({ 
				shopFruitId: $stateParams.shopFruitId
			});
		};
	}
]);

{'fraction_non_alphanumeric': 0.15417461615335695, 'fraction_numerical': 0.005360225311165622, 'mean_word_length': 2.276190476190476, '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': '140549', 'n_tokens_mistral': 3740, 'n_tokens_neox': 3420, 'n_words': 575}