<commit_before>var topicservices = angular.module('crmEngine.taskservices',[]);

topicservices.factory('Task', function($http) {

  var Task = function(data) {
    angular.extend(this, data);
  }


 Task.get = function($scope,id) {
     $scope.inProcess(true);  
          gapi.client.crmengine.tasks.get(id).execute(function(resp) {
            if(!resp.code){
               $scope.task = resp;
               if($scope.task.about){
                var url = Task.getUrl($scope.task.about.kind,$scope.task.about.id);
               $scope.uri =url;
               }
               $scope.isContentLoaded = true;

               $scope.ListComments();
               $scope.listContributors();
               document.title = "Task: " + $scope.task.title ;
               // $scope.isContentLoaded = true;
               // $scope.listTopics(resp);
               // $scope.listTasks();
               // $scope.listEvents();
               // Call the method $apply to make the update on the scope               
            }else {
               if(resp.code==401){
                $scope.refreshToken();
                $scope.isLoadingTask = false;
               };
            }
          });
          $scope.apply();
     $scope.inProcess(false);  

  };
  
Task.get_docs=function($scope,params){
  $scope.inProcess(true);  
  gapi.client.crmengine.tasks.get_docs(params).execute(function(resp) {
           if(!resp.code){
          $scope.files=resp.items;
           }else{
             
           }
        


  });
  $scope.inProcess(false);  

}

  Task.patch = function($scope,params){
      $scope.inProcess(true);  
      gapi.client.crmengine.tasks.patch(params).execute(function(resp) {

          if(!resp.code){
            $scope.task = resp;
             $scope.listTags();
             if (!$scope.taskShow) {
              $scope.listTasks();
             };
            $('#EditTaskModal').modal('hide');

         }else{
             $('#EditTaskModal').modal('hide');
             $('#errorModal').modal('show');
             if(resp.message=="Invalid grant"){
              console.log("Invalid grant");
                $scope.refreshToken();
                $scope.listTags();
                $scope.listTasks();
             };
         }
      });
     $scope.apply();  
     $scope.inProcess(false);  

  };

  Task.list = function($scope,params,effects){
      $scope.blankStateTask= false;
      $scope.inProcess(true);  
      gapi.client.crmengine.tasks.listv2(params).execute(function(resp) {

              if(!resp.code){
                if (!resp.items){
                    if(!$scope.isFiltering){
                        $scope.blankStateTask= true;
                       
         
                    }
                    $scope.tasks = resp.items;
                     $scope.$apply()
                  }else{
                 $scope.tasks = resp.items;
                  if ($scope.currentPage>1){
                      $scope.taskpagination.prev = true;
                   }else{
                       $scope.taskpagination.prev = false;
                   }
                 if (resp.nextPageToken){
                   var nextPage = $scope.currentPage + 1;
                   // Store the nextPageToken
                   $scope.pages[nextPage] = resp.nextPageToken;
                   $scope.taskpagination.next = true;

                 }else{
                  $scope.taskpagination.next = false;
                 }
                 // Call the method $apply to make the update on the scope
                 $scope.blankStateTask= false;
                 $scope.isLoading = false;
                 $scope.$apply();

               /* $scope.tasks = resp.items;

                // Loaded succefully

                 $scope.isLoading = false;

                 // Call the method $apply to make the update on the scope
                 $scope.$apply();
                 if (effects){
                     $scope.hilightTask();

                 }*/
                  $scope.apply();
                  $scope.inProcess(false);
              }else {
                 if(resp.code==401){
                    $scope.refreshToken();
                     $scope.apply();
                    $scope.inProcess(false);  
               };
              }
      });
  };
   Task.insert = function($scope,params){
      $scope.inProcess(true);  
      gapi.client.crmengine.tasks.insertv2(params).execute(function(resp) {


         if(!resp.code){

          if ($scope.tasks == undefined){
            $scope.tasks = [];
          }
            $scope.tasks.push(resp);
            $scope.justaddedtask=resp ;
            $scope.listTags();
           
            if ($scope.selectedTab==2){
              $scope.urgentTasks();
            }else{
               $scope.listTasks();
            }
         }else{
          console.log(resp.code);<commit_msg>fix a bug in the taskservices<commit_after>var topicservices = angular.module('crmEngine.taskservices',[]);

topicservices.factory('Task', function($http) {

  var Task = function(data) {
    angular.extend(this, data);
  }


 Task.get = function($scope,id) {
     $scope.inProcess(true);  
          gapi.client.crmengine.tasks.get(id).execute(function(resp) {
            if(!resp.code){
               $scope.task = resp;
               if($scope.task.about){
                var url = Task.getUrl($scope.task.about.kind,$scope.task.about.id);
               $scope.uri =url;
               }
               $scope.isContentLoaded = true;

               $scope.ListComments();
               $scope.listContributors();
               document.title = "Task: " + $scope.task.title ;
               // $scope.isContentLoaded = true;
               // $scope.listTopics(resp);
               // $scope.listTasks();
               // $scope.listEvents();
               // Call the method $apply to make the update on the scope               
            }else {
               if(resp.code==401){
                $scope.refreshToken();
                $scope.isLoadingTask = false;
               };
            }
          });
          $scope.apply();
     $scope.inProcess(false);  

  };
  
Task.get_docs=function($scope,params){
  $scope.inProcess(true);  
  gapi.client.crmengine.tasks.get_docs(params).execute(function(resp) {
           if(!resp.code){
          $scope.files=resp.items;
           }else{
             
           }
        


  });
  $scope.inProcess(false);  

}

  Task.patch = function($scope,params){
      $scope.inProcess(true);  
      gapi.client.crmengine.tasks.patch(params).execute(function(resp) {

          if(!resp.code){
            $scope.task = resp;
             $scope.listTags();
             if (!$scope.taskShow) {
              $scope.listTasks();
             };
            $('#EditTaskModal').modal('hide');

         }else{
             $('#EditTaskModal').modal('hide');
             $('#errorModal').modal('show');
             if(resp.message=="Invalid grant"){
              console.log("Invalid grant");
                $scope.refreshToken();
                $scope.listTags();
                $scope.listTasks();
             };
         }
      });
     $scope.apply();  
     $scope.inProcess(false);  

  };

  Task.list = function($scope,params,effects){
      $scope.blankStateTask= false;
      $scope.inProcess(true);  
      gapi.client.crmengine.tasks.listv2(params).execute(function(resp) {

              if(!resp.code){
                if (!resp.items){
                    if(!$scope.isFiltering){
                        $scope.blankStateTask= true;
                       
         
                    }
                    $scope.tasks = resp.items;
                     $scope.$apply()
                  }else{
                 $scope.tasks = resp.items;
                  if ($scope.currentPage>1){
                      $scope.taskpagination.prev = true;
                   }else{
                       $scope.taskpagination.prev = false;
                   }
                 if (resp.nextPageToken){
                   var nextPage = $scope.currentPage + 1;
                   // Store the nextPageToken
                   $scope.pages[nextPage] = resp.nextPageToken;
                   $scope.taskpagination.next = true;

                 }else{
                  $scope.taskpagination.next = false;
                 }
                 // Call the method $apply to make the update on the scope
                 $scope.blankStateTask= false;
                 $scope.isLoading = false;
                 $scope.$apply();

               /* $scope.tasks = resp.items;

                // Loaded succefully

                 $scope.isLoading = false;

                 // Call the method $apply to make the update on the scope
                 $scope.$apply();
                 if (effects){
                     $scope.hilightTask();

                 }*/
                  $scope.apply();
                  $scope.inProcess(false);
              }
            }else {
                 if(resp.code==401){
                    $scope.refreshToken();
                     $scope.apply();
                    $scope.inProcess(false);  
               };
              }
      });
  };
   Task.insert = function($scope,params){
      $scope.inProcess(true);  
      gapi.client.crmengine.tasks.insertv2(params).execute(function(resp) {


         if(!resp.code){

          if ($scope.tasks == undefined){
            $scope.tasks = [];
          }
            $scope.tasks.push(resp);
            $scope.justaddedtask=resp ;
            $scope.listTags();
           
            if ($scope.selectedTab==2){
              $scope.urgentTasks();
            }else{
               $scope.listTasks();
            }
         }else{
          console.log(resp.code);
{'fraction_non_alphanumeric': 0.13210804224207962, 'fraction_numerical': 0.0022339561332250205, 'mean_word_length': 1.2358683314415437, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4813381', 'n_tokens_mistral': 2664, 'n_tokens_neox': 2550, 'n_words': 380}