Skip to content

Commit

Permalink
add invalid flag to record
Browse files Browse the repository at this point in the history
remove invalid records
add understanding for 'removed time spent' -> invalidating all previous records of an issue
  • Loading branch information
moritzschiesser committed Mar 17, 2021
1 parent db729b2 commit e0d6112
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
14 changes: 5 additions & 9 deletions gttcharts/Charting/GttChartBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public class GttChartBuilder
public GttChartBuilder(GttChartsOptions options, IEnumerable<Issue> issues, IEnumerable<Record> records)
{
this.options = options;
this.issues = issues;
this.records = records;
utils = new GttChartBuilderUtils(issues, records, this.options);
dataProvider = new GttDataQueryProvider(issues, records, options, utils);
this.issues = issues;
this.records = records;
utils = new GttChartBuilderUtils(issues, records, this.options);
dataProvider = new GttDataQueryProvider(issues, records, options, utils);
}

#region Graphing
Expand Down Expand Up @@ -108,12 +108,8 @@ private void CreateTimePerIssue(Plot plt)
string[] issues = perIssue.Select(i => i.Title).ToArray();
double[] estimates = perIssue.Select(p => utils.Round(p.TotalEstimate)).ToArray();
double[] spent = perIssue.Select(p => utils.Round(p.Spent)).ToArray();
//double[] actualSpent = perIssue.Select(p => utils.Round(records.Where(r => r.Iid == p.Iid).Sum(r => r.Time))).ToArray();

/*
new string[] { "estimated", "spent", "actualspent" },
new double[][] { estimates, spent, actualSpent },
*/

plt.PlotBarGroups(
issues,
new string[] { "estimated", "spent" },
Expand Down
21 changes: 16 additions & 5 deletions gttcharts/Data/GitlabAPIConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,20 @@ public GitlabAPIConsumer(GitlabAPIOptions options)
StyledConsoleWriter.WriteInfo($"Getting notes for {issue.Title}");
var notesList = await client.Issues.GetNotesAsync(options.Project, issue.Iid);
// process notes generated by system
// todo: do we need to do this parallel? Might be an overkill...
Parallel.ForEach(notesList.Where(n => n.System == true), (note) =>
// it seems like we need to order the notes ourselfes - gitlab just doesn't care^^
foreach(var note in notesList.Where(n => n.System == true).OrderBy(n => n.Id))
{
if (note.Body.Contains("time spent"))
if (note.Body.Contains("removed time spent"))
{
// this note indicates, that all previous time-entries are not valid
// (I just hope gitlab does send the notes ordered the correct way, currently don't have a lot of trust in this system anymore...)
var prevRecs = records.Where(r => r.Iid == issue.Iid);
foreach (var prevRec in prevRecs)
{
prevRec.IsInavlidated = true;
}
}
else if (note.Body.Contains("time spent"))
{
var timeData = timeParser.GetSpentHours(note);
records.Add(new Models.Record()
Expand All @@ -88,10 +98,11 @@ public GitlabAPIConsumer(GitlabAPIOptions options)
NoteBody = note.Body
});
}
});
}
}

return (true, issues, records);
// remove invalid records here, no need to have them in the dataset...
return (true, issues, records.Where(r => r.IsInavlidated == false));
}
}
}
1 change: 1 addition & 0 deletions gttcharts/Models/Record.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public partial class Record
public double Time { get; set; }
public int NoteIid { get; set; }
public string NoteBody { get; set; }
public bool IsInavlidated { get; set; }
}
}

0 comments on commit e0d6112

Please sign in to comment.