-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Indicador 3, rendimiento de un desarrollador
Rendimiento de un desarrollador en comparación con el equipo Tiene problemas, sobre todo no obtiene las métricas bien También se hacen Arreglos Gradle
- Loading branch information
1 parent
5361913
commit da4d75c
Showing
12 changed files
with
749 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-wrapper.jar.sha256 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
88 changes: 88 additions & 0 deletions
88
src/main/java/us/muit/fs/a4i/control/strategies/DeveloperPerformanceStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* | ||
*/ | ||
package us.muit.fs.a4i.control.strategies; | ||
|
||
import us.muit.fs.a4i.control.IndicatorStrategy; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.logging.Logger; | ||
|
||
import us.muit.fs.a4i.exceptions.NotAvailableMetricException; | ||
import us.muit.fs.a4i.exceptions.ReportItemException; | ||
import us.muit.fs.a4i.model.entities.Indicator; | ||
import us.muit.fs.a4i.model.entities.IndicatorI.IndicatorState; | ||
import us.muit.fs.a4i.model.entities.ReportItem; | ||
import us.muit.fs.a4i.model.entities.ReportItemI; | ||
|
||
/** | ||
* Strategy for the calculation of a developer performance comparing him with | ||
* the rest of developers | ||
* | ||
* @author fracrusan (year 23/24) | ||
* @author Isabel Román | ||
*/ | ||
public class DeveloperPerformanceStrategy implements IndicatorStrategy<Double> { | ||
|
||
private static Logger log = Logger.getLogger(Indicator.class.getName()); | ||
// M�tricas necesarias para calcular el indicador | ||
private static final List<String> REQUIRED_METRICS = Arrays.asList("issuesLastMonth", "closedIssuesLastMonth", | ||
"issues4DevLastMonth", "meanClosedIssuesLastMonth"); | ||
|
||
@Override | ||
public ReportItemI calcIndicator(List metrics) throws NotAvailableMetricException { | ||
// Se obtienen y se comprueba que se pasan las m�tricas necesarias para calcular | ||
// el indicador. | ||
Optional<ReportItemI<Integer>> issuesLastMonth = metrics.stream() | ||
.filter(m -> REQUIRED_METRICS.get(0).equals(((ReportItemI) m).getName())).findAny(); | ||
Optional<ReportItemI<Integer>> closedIssuesLastMonth = metrics.stream() | ||
.filter(m -> REQUIRED_METRICS.get(1).equals(((ReportItemI) m).getName())).findAny(); | ||
Optional<ReportItemI<Double>> issues4DevLastMonth = metrics.stream() | ||
.filter(m -> REQUIRED_METRICS.get(2).equals(((ReportItemI) m).getName())).findAny(); | ||
Optional<ReportItemI<Double>> meanClosedIssuesLastMonth = metrics.stream() | ||
.filter(m -> REQUIRED_METRICS.get(3).equals(((ReportItemI) m).getName())).findAny(); | ||
ReportItemI<Double> indicatorReport = null; | ||
|
||
if (issuesLastMonth.isPresent() && closedIssuesLastMonth.isPresent() && issues4DevLastMonth.isPresent() | ||
&& meanClosedIssuesLastMonth.isPresent()) { | ||
Double rendimientoMiembro; | ||
|
||
// calculating indicator | ||
if (issuesLastMonth.get().getValue() != 0 && issues4DevLastMonth.get().getValue() != 0 | ||
&& meanClosedIssuesLastMonth.get().getValue() != 0) | ||
rendimientoMiembro = (closedIssuesLastMonth.get().getValue() / issuesLastMonth.get().getValue()) | ||
/ (meanClosedIssuesLastMonth.get().getValue() / issues4DevLastMonth.get().getValue()); | ||
else if (meanClosedIssuesLastMonth.get().getValue() != 0) | ||
rendimientoMiembro = 1.0; | ||
else | ||
rendimientoMiembro = 0.0; | ||
|
||
try { | ||
// Se crea el indicador | ||
indicatorReport = new ReportItem.ReportItemBuilder<Double>("rendimientoMiembro", rendimientoMiembro) | ||
.metrics(Arrays.asList(issuesLastMonth.get(), closedIssuesLastMonth.get(), | ||
issues4DevLastMonth.get(), meanClosedIssuesLastMonth.get())) | ||
.indicator(IndicatorState.UNDEFINED).build(); | ||
} catch (ReportItemException e) { | ||
log.info("Error en ReportItemBuilder."); | ||
e.printStackTrace(); | ||
} | ||
|
||
} else { | ||
log.info("No se han proporcionado las m�tricas necesarias"); | ||
throw new NotAvailableMetricException(REQUIRED_METRICS.toString()); | ||
} | ||
|
||
return indicatorReport; | ||
} | ||
|
||
@Override | ||
public List<String> requiredMetrics() { | ||
// Para calcular el indicador "rendimientoMiembro", ser�n necesarias las | ||
// m�tricas | ||
// "openIssues" y "closedIssues". | ||
return REQUIRED_METRICS; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
src/main/java/us/muit/fs/a4i/model/remote/GitHubDeveloperEnquirer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/** | ||
* | ||
*/ | ||
package us.muit.fs.a4i.model.remote; | ||
|
||
import java.util.List; | ||
import java.util.logging.Logger; | ||
|
||
import org.kohsuke.github.GHEvent; | ||
import org.kohsuke.github.GHEventInfo; | ||
import org.kohsuke.github.GHEventPayload; | ||
import org.kohsuke.github.GHProject; | ||
import org.kohsuke.github.GHRepository; | ||
import org.kohsuke.github.GHUser; | ||
import org.kohsuke.github.GitHub; | ||
import org.kohsuke.github.PagedIterable; | ||
|
||
import us.muit.fs.a4i.exceptions.MetricException; | ||
import us.muit.fs.a4i.model.entities.ReportI; | ||
import us.muit.fs.a4i.model.entities.ReportItem; | ||
|
||
import us.muit.fs.a4i.model.entities.ReportItem.ReportItemBuilder; | ||
|
||
/** | ||
* Deuda técnica | ||
* Esta clase debe consultar datos sobre un desarrollador concreto de github | ||
* Ahora mismo está en estado lamentable | ||
* Simplemente busca los eventos de un desarrollador | ||
* No localiza eventos de tipo ISSUE, que son los que se quería | ||
*/ | ||
public class GitHubDeveloperEnquirer extends GitHubEnquirer { | ||
public GitHubDeveloperEnquirer() { | ||
super(); | ||
metricNames.add("closedIssuesLastMonth"); | ||
metricNames.add("assignedIssuesLastMonth"); | ||
log.info("Incluidos nombres metricas en Enquirer"); | ||
} | ||
|
||
private static Logger log = Logger.getLogger(GitHubDeveloperEnquirer.class.getName()); | ||
/** | ||
* <p> | ||
* Identificador unívoco de la entidad a la que se refire el informe en el | ||
* servidor remoto que se va a utilizar | ||
* </p> | ||
*/ | ||
private String entityId; | ||
@Override | ||
public ReportI buildReport(String developerId) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public ReportItem getMetric(String metricName, String developerId) throws MetricException { | ||
GHUser developer; | ||
|
||
GitHub gb = getConnection(); | ||
try { | ||
developer = gb.getUser(developerId); | ||
log.info("Localizado el desarrollador "+developer.getName()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
throw new MetricException( | ||
"No se puede acceder al desarrollador " + developerId + " para recuperarlo"); | ||
} | ||
|
||
return getMetric(metricName, developer); | ||
} | ||
|
||
private ReportItem getMetric(String metricName, GHUser developer) throws MetricException { | ||
log.info("Localizando la metrica "+metricName); | ||
ReportItem metric; | ||
if (developer == null) { | ||
throw new MetricException("Intenta obtener una métrica de desarrollador sin haber obtenido el desarrollador"); | ||
} | ||
switch (metricName) { | ||
case "closedIssuesLastMonth": | ||
metric = getClosedIssuesLastMonth(developer); | ||
break; | ||
case "assignedIssuesLastMonth": | ||
metric = getAssignedIssuesLastMonth(developer); | ||
break; | ||
default: | ||
throw new MetricException("La métrica " + metricName + " no está definida para un repositorio"); | ||
} | ||
|
||
return metric; | ||
} | ||
|
||
private ReportItem getClosedIssuesLastMonth(GHUser developer) { | ||
log.info("Consultando los issues asignados a un desarrollador"); | ||
ReportItemBuilder<Integer> builder = null; | ||
int issues=0; | ||
|
||
try { | ||
PagedIterable <GHEventInfo> events=developer.listEvents(); | ||
for(GHEventInfo event:events) { | ||
log.info("Evento tipo"+event.getType()+" en la fecha "+event.getCreatedAt()); | ||
if(event.getType()==GHEvent.ISSUES) { | ||
|
||
GHEventPayload.Issue payload=event.getPayload(GHEventPayload.Issue.class); | ||
log.info(payload.getAction()); | ||
issues++; | ||
|
||
} | ||
|
||
} | ||
builder = new ReportItem.ReportItemBuilder<Integer>("closedIssuesLastMonth", issues); | ||
builder.source("GitHub"); | ||
} catch (Exception e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
return builder.build(); | ||
} | ||
|
||
private ReportItem getAssignedIssuesLastMonth(GHUser developer) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.