private List<Developer> SimpleSearch(ProfileMatchConfig config, string[] queries) {
            List<Developer> searchResult = new List<Developer>();
            int sed = config.no_of_sed;
            int ned = config.no_of_ned;
            int fd = config.no_of_fd;
            foreach (var query in queries)
            {
                if (sed <= 0 && ned <= 0 && fd <= 0)
                {
                    break;
                }
                if (queries[0] == "General") {
                    int a = 0;
                }
                SearchResultCollection Results = searchManager.Search(query, 0, 1000, Searchable.AnalyzedFields.Values.ToArray());
              
                foreach (var result in Results.Data)
                {
                    result.Parse(x =>
                    {
                        result.Name = x.Get(Searchable.FieldStrings[Searchable.Field.Name]).Trim();
                        result.Product = x.Get(Searchable.FieldStrings[Searchable.Field.Product]);
                        result.Component = x.Get(Searchable.FieldStrings[Searchable.Field.Component]);
                        result.Skill = x.Get(Searchable.FieldStrings[Searchable.Field.Skill]);
                        result.DeveloperType = int.Parse(x.Get(Searchable.FieldStrings[Searchable.Field.DeveloperType]));
                    });
                    if (ned > 0 && result.DeveloperType == 2) {
                        searchResult.Add(new Developer { DeveloperName = result.Name, DeveloperId = result.DeveloperType });
                        ned--;
                        continue;
                    }
                    if (fd > 0 && result.DeveloperType == 3) {
                        searchResult.Add(new Developer { DeveloperName = result.Name, DeveloperId = result.DeveloperType });
                        fd--;
                        continue;
                    }
                    if (sed > 0 && result.DeveloperType == 1) {
                        searchResult.Add(new Developer { DeveloperName = result.Name, DeveloperId = result.DeveloperType });
                        sed--;
                        continue;
                    }
                   
                   
                  

                }
            }

             var finalResultset = searchResult.GroupBy(x => x.DeveloperName).Select(s => new Developer
                {
                    DeveloperName = s.Key,
                    DeveloperId = s.Select(x => x.DeveloperId).FirstOrDefault(),
                    current_workload = s.Select(x => x.DeveloperName).Count()
                }).OrderByDescending(x => x.current_workload).ToList();
            return finalResultset;
        }
Ejemplo n.º 2
0
 public Confirmation GetSearchProfileConfig(string severity)
 {
     try
     {
         ProfileMatchConfig config = context.profile_match_config.FirstOrDefault(x => x.severity == severity);
         int row = (config == null) ?0:1;
         return(new Confirmation {
             is_succeed = true, output = config, msg = row + " Result Found"
         });
     }
     catch (Exception e)
     {
         return(new Confirmation {
             is_succeed = true, msg = e.Message
         });
     }
 }
 public IActionResult SearchProfileConfig(ProfileMatchConfigViewModel config)
 {
     if (ModelState.IsValid)
     {
         ProfileMatchConfig matchConfig = new ProfileMatchConfig
         {
             profile_match_config_id = config.profile_match_config_id,
             severity  = config.severity,
             no_of_sed = config.no_of_sed,
             no_of_ned = config.no_of_ned,
             no_of_fd  = config.no_of_fd,
         };
         Confirmation res = bugRepository.SaveSearchProfileConfig(matchConfig);
         if (res.is_succeed)
         {
             ViewData["success"] = res.msg;
         }
         else
         {
             ViewData["error"] = res.msg;
         }
     }
     return(View(config));
 }
        public object PredictDeveloper()
        {
                    string searchType = Request.Form["type"].ToString();
                    IFormFile file = Request.Form.Files[0];

                    int type = int.Parse(searchType);
                    List<BugModel> bugs=GetBugsFromExcel(file);

                    string allProducts="";
                    string allComponents="";
                    string allDeveopers="";

                    decimal totalPrecision = 0;
                    decimal totalRecall = 0;
                    decimal totalFscore = 0;
                    foreach (var item in bugs)
                    {
                        allProducts += item.ProductName+",";
                        allComponents += item.ComponentName+",";
                        allDeveopers += item.AssigneeName+",";
                        string saverity = GetSaverityForSearch(item.SeverityTitle);
                        ProfileMatchConfig config = developerRepository.GetConfig(saverity);
                        int sed = config.no_of_sed;
                        int ned = config.no_of_ned;
                        int fd = config.no_of_fd;
                        string query = item.ComponentName;

                        string []queryOne = new[] { item.ComponentName, item.ProductName, item.KeyWords };
                        string []queryTwo = new[] { item.ComponentName+','+item.ProductName+','+item.KeyWords };

                        List<Developer> finalResultset = SimpleSearch(config, (type==1)? queryOne: queryTwo);

                        item.predictedDevelopers = finalResultset;


                        int match = 0;
                        finalResultset.ForEach(x => {
                           
                            var contains = item.AssigneeName.Contains(x.DeveloperName);
                            if (contains) match++;
                        });
                        decimal actualDevelopers = item.AssigneeName.Split(',').Count();
                        decimal methodDevelopers= finalResultset.Count;
                        methodDevelopers=(methodDevelopers == 0) ? methodDevelopers = 1: methodDevelopers;
                        actualDevelopers = (actualDevelopers == 0) ? actualDevelopers = 1: actualDevelopers;
                        decimal precision = (match / methodDevelopers);
                        decimal recall = match / actualDevelopers;
                        decimal precall = (precision + recall);
                        decimal fScore = 2 * ((precision * recall) / ((precall==0)?1:precall));

                        item.Precision = precision;
                        item.Recall = recall;
                        item.Fscore = fScore;

                        totalPrecision += precision;
                        totalRecall += recall;
                        totalFscore += fScore;


                    }

                    var summary = new SummaryModel();
                    summary.Bugs = bugs.Count();
                    summary.AvaragePrecesion = totalPrecision / summary.Bugs;
                    summary.AvarageRecall = totalRecall / summary.Bugs;
                    summary.AvarageFscore = totalFscore / summary.Bugs;

                    int productCount= allProducts.Split(',').Distinct().Count();
                    int ComponentCount = allComponents.Split(',').Distinct().Count();
                    summary.Products = productCount > 0 ? (productCount - 1) : 0;
                    summary.Components = ComponentCount > 0 ? (ComponentCount - 1) : 0;
                    summary.Developers = allDeveopers.Split(',').Distinct().Count();
                    return new {bugs,summary};
           
            //return this.Content(sb.ToString());
        }