Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ an old one next to it is left alone, you can delete it.
The table with the players who failed the most mechanics comes from the encounter (trigger) id of the log.
Encounters without a definition (strikes, fractals, new content) show the three mechanics the players triggered most.

#### Statistics of one boss over several weeks

`rta parse boss <name> [--cm] [--from yyyyMMdd] [--to yyyyMMdd] [--phases 70,40,10] [-k] [-r]` loads every log of one boss from your dps.report
uploads (the name only has to contain the text, e.g. `Cairn`; bosses dps.report does not know by name are listed as "DPS.Report", use their id then: `28106` or `0x6DCA`), builds `boss-<name>-stats.html` (a stand-alone statistics page: boss health left per try and day, days, where the wipes end, players, latest tries) and `boss-<name>.html` (the timeline, open the
Boss tab) in your `outputPath` and prints tries, kills, fastest kill, best wipe and one line per day. The list of uploads and the logs are cached in the log folder of rta (`dpsreport-cache`), so a later
run only reads the new uploads and loads the new logs (`--refresh` reads the whole list again).
`--phases` takes the boss health (percent left) where a new phase starts; the statistics then draw the phases as bands in the chart and show how far every day got.

#### dps.report upload

Please use the dps.report upload with care and do not spam it with all logs that you have.
Expand Down
42 changes: 42 additions & 0 deletions raidTimeline.App.Tests/BossSummaryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using raidTimeline.App.Services;
using raidTimeline.Models.Models;
using Xunit;

namespace raidTimeline.App.Tests;

public sealed class BossSummaryTests
{
private static RaidModel Try(DateTime start, int seconds, bool killed, double hpLeft) =>
new("log")
{
EncounterName = "Cairn",
OccurenceStart = start,
OccurenceEnd = start.AddSeconds(seconds),
Killed = killed,
HpLeft = { hpLeft }
};

[Fact]
public void Create_SummarizesTriesKillsAndDays()
{
var lines = BossSummary.Create(new[]
{
Try(new DateTime(2026, 11, 2, 20, 0, 0), 120, false, 55.5),
Try(new DateTime(2026, 11, 2, 20, 10, 0), 200, false, 12),
Try(new DateTime(2026, 11, 9, 20, 0, 0), 180, true, 0),
Try(new DateTime(2026, 11, 9, 20, 10, 0), 150, true, 0)
});

Assert.Contains("Cairn: 4 tries on 2 days, 2 kills (02.11.2026 - 09.11.2026)", lines);
Assert.Contains("Fastest kill: 2:30 on 09.11.2026", lines);
Assert.Contains("Best wipe: 12% boss health left on 02.11.2026, after 3:20", lines);
Assert.Contains(lines, l => l.StartsWith("02.11.2026") && l.EndsWith("12% left"));
Assert.Contains(lines, l => l.StartsWith("09.11.2026") && l.EndsWith("kill"));
}

[Fact]
public void Create_NoLogs_SaysSo()
{
Assert.Equal(new[] { "No logs found." }, BossSummary.Create(Array.Empty<RaidModel>()));
}
}
50 changes: 50 additions & 0 deletions raidTimeline.App/Commands/ParserCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ namespace raidTimeline.App.Commands;

internal static class ParserCommands
{
private static IReadOnlyList<double>? ParsePhases(string? phases)
{
if (string.IsNullOrWhiteSpace(phases)) return null;

var values = phases.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
.Select(p => double.TryParse(p.TrimEnd('%'), System.Globalization.NumberStyles.Float,
System.Globalization.CultureInfo.InvariantCulture, out var v) && v is > 0 and < 100 ? v : double.NaN)
.ToList();
if (values.Count == 0 || values.Any(double.IsNaN))
{
throw new ArgumentException("--phases needs percentages between 0 and 100, e.g. 70,40,10.");
}

return values.Distinct().OrderByDescending(v => v).ToList();
}

private static DateOnly? ParseDay(string? day) =>
day == null ? null : DateOnly.ParseExact(day, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);

internal static CoconaApp RegisterParserCommands(this CoconaApp app)
{
app.AddSubCommand("parse", command =>
Expand Down Expand Up @@ -51,6 +70,37 @@ bool filter
})
.WithDescription("Parses local log files with Elite Insights and keeps watching for new logs.");

command.AddCommand("boss",
([FromService] IParserService parserService,
CoconaAppContext context,
[Argument(Description = "Part of the boss name (e.g. \"Cairn\") or the boss id (e.g. 28106 or 0x6DCA).")]
string boss,
[Option('c', Description = "Only logs of the challenge mode.")]
bool cm,
[Day][Option("from",
Description = "First day (format: yyyyMMdd). Default is all days.")]
string? from,
[Day][Option("to",
Description = "Last day (format: yyyyMMdd). Default is all days.")]
string? to,
[Option('r', Description = "Creates the timeline in reverse date order.")]
bool reverse,
[Option('k', Description = "Only uses the logs that killed the boss.")]
bool killOnly,
[Option("refresh", Description = "Reads the whole list of uploads from dps.report again instead of only the new ones.")]
bool refresh,
[Option("phases", Description = "Boss health in percent where a new phase starts, comma separated, e.g. 70,40,10. Shown in the statistics.")]
string? phases
) =>
{
parserService.ParseBossFromDpsReport(boss, cm, ParseDay(from), ParseDay(to), killOnly,
reverse, refresh, ParsePhases(phases), context.CancellationToken);
})
.WithDescription(
"Loads all logs of one boss (e.g. every try at a challenge mode over weeks) from dps.report " +
"and creates a statistics page (boss-<name>-stats.html) and a timeline (boss-<name>.html). " +
"Uploads and logs are kept locally, so later runs only load the new ones.");

command.AddCommand("report",
([FromService] IParserService parserService,
CoconaAppContext context,
Expand Down
62 changes: 62 additions & 0 deletions raidTimeline.App/Services/BossSummary.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System.Globalization;
using raidTimeline.Models.Models;

namespace raidTimeline.App.Services;

/// <summary>A short text summary of all tries at one boss, printed after the timeline was built.</summary>
internal static class BossSummary
{
internal static IReadOnlyList<string> Create(IReadOnlyCollection<RaidModel> models)
{
var ci = CultureInfo.InvariantCulture;
var lines = new List<string>();
var tries = models.OrderBy(m => m.OccurenceStart).ToList();

if (tries.Count == 0)
{
lines.Add("No logs found.");
return lines;
}

var kills = tries.Where(m => m.Killed).ToList();
lines.Add($"{tries[0].EncounterName}: {tries.Count} tries on {tries.Select(m => m.OccurenceStart.Date).Distinct().Count()} days, " +
$"{kills.Count} kill{(kills.Count == 1 ? "" : "s")} ({tries[0].OccurenceStart:dd.MM.yyyy} - {tries[^1].OccurenceStart:dd.MM.yyyy})");

if (kills.Count > 0)
{
var fastest = kills.MinBy(Duration)!;
lines.Add($"Fastest kill: {Format(Duration(fastest))} on {fastest.OccurenceStart:dd.MM.yyyy}");
}

var wipes = tries.Where(m => !m.Killed && m.HpLeft.Count > 0).ToList();
if (wipes.Count > 0)
{
var best = wipes.MinBy(HpLeft)!;
lines.Add($"Best wipe: {HpLeft(best).ToString("0.##", ci)}% boss health left on {best.OccurenceStart:dd.MM.yyyy}, " +
$"after {Format(Duration(best))}");
}

lines.Add(string.Empty);
lines.Add("Day Tries Kills Best try");
foreach (var day in tries.GroupBy(m => m.OccurenceStart.Date).OrderBy(g => g.Key))
{
var dayKills = day.Count(m => m.Killed);
var bestTry = day.Any(m => m.Killed)
? "kill"
: day.Where(m => m.HpLeft.Count > 0).Select(HpLeft).DefaultIfEmpty(double.NaN).Min() is var hp &&
!double.IsNaN(hp)
? $"{hp.ToString("0.##", ci)}% left"
: "-";
lines.Add($"{day.Key:dd.MM.yyyy} {day.Count(),5} {dayKills,5} {bestTry}");
}

return lines;
}

/// <summary>Health left of the boss; for several targets the one with the most left decides.</summary>
private static double HpLeft(RaidModel model) => model.HpLeft.Max();

private static TimeSpan Duration(RaidModel model) => model.OccurenceEnd - model.OccurenceStart;

private static string Format(TimeSpan time) => $"{(int)time.TotalMinutes}:{time.Seconds:00}";
}
2 changes: 2 additions & 0 deletions raidTimeline.App/Services/Interfaces/IParserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ void ParseLogsFromDisk(string? day, bool reverse, bool killOnly, bool filter,
IEncounterService encounterService, CancellationToken cancellationToken, bool htmlOnly = false);
void ParseLogsFromDiskLive(bool reverse, bool killOnly, bool filter,
CancellationToken cancellationToken);
void ParseBossFromDpsReport(string boss, bool challengeMode, DateOnly? from, DateOnly? to, bool killOnly,
bool reverse, bool refresh, IReadOnlyList<double>? phases, CancellationToken cancellationToken);
void ParseLogsFromDpsReport(string? day, bool reverse, bool killOnly, bool filter,
CancellationToken cancellationToken);
}
66 changes: 65 additions & 1 deletion raidTimeline.App/Services/ParserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using raidTimeline.App.Helpers;
using raidTimeline.App.Services.Interfaces;
using raidTimeline.Database.Interfaces;
using raidTimeline.Logic.DpsReport;
using raidTimeline.Logic.Interfaces;
using raidTimeline.Models.Models;

Expand All @@ -13,10 +14,14 @@ internal class ParserService : IParserService
private readonly ConfigurationHelper _configurationHelper;
private readonly IEliteInsightsService _eliteInsightsService;

private readonly AppPaths _paths;

public ParserService(ITimelineCreator timelineCreator,
ConfigurationHelper configurationHelper,
IEliteInsightsService eliteInsightsService)
IEliteInsightsService eliteInsightsService,
AppPaths paths)
{
_paths = paths;
_timelineCreator = timelineCreator;
_configurationHelper = configurationHelper;
_eliteInsightsService = eliteInsightsService;
Expand Down Expand Up @@ -218,6 +223,65 @@ private IList<RaidModel> ParseNewModels(IList<RaidModel> models, bool reverse, b
return models;
}

public void ParseBossFromDpsReport(string boss, bool challengeMode, DateOnly? from, DateOnly? to, bool killOnly,
bool reverse, bool refresh, IReadOnlyList<double>? phases, CancellationToken cancellationToken)
{
var cmText = challengeMode ? " CM" : "";
Spinner.Start($"Loading the logs of {boss}{cmText} from dps.report", spinner =>
{
if (string.IsNullOrWhiteSpace(_configurationHelper.Configuration.DpsReportToken))
{
spinner.Fail("There is no dpsReportToken in your settings (see rta config edit).");
return;
}

IList<RaidModel> models;
try
{
var filter = new DpsReportFilter(from, to, boss, challengeMode);
models = _timelineCreator.ParseFilesFromWeb(_configurationHelper.Configuration.DpsReportToken, filter,
Path.Combine(_paths.LogDirectory, "dpsreport-cache"),
(done, total) => spinner.Text = $"Loading the logs of {boss}{cmText} from dps.report: {done}/{total}",
cancellationToken, refresh);
}
catch (HttpRequestException e)
{
spinner.Fail($"dps.report could not be reached: {e.Message}");
return;
}

if (cancellationToken.IsCancellationRequested)
{
spinner.Info("Log parsing canceled.");
return;
}

if (killOnly) models = models.Where(model => model.Killed).ToList();

if (models.Count == 0)
{
spinner.Warn($"No logs of {boss}{cmText} found.");
return;
}

var slug = new string($"{boss}{cmText}".ToLowerInvariant()
.Select(c => char.IsLetterOrDigit(c) ? c : '-').ToArray()).Trim('-');
var fileName = $"boss-{slug}.html";
var statsFileName = $"boss-{slug}-stats.html";

spinner.Text = "Creating timeline and statistics";
var outputPath = _configurationHelper.Configuration.OutputPath;
_timelineCreator.BuildTimelineFile(outputPath, fileName, models, reverse, cancellationToken);
_timelineCreator.BuildBossStatisticsFile(outputPath, statsFileName, models, phases, cancellationToken);

spinner.Succeed($"{models.Count} logs");
Console.WriteLine($"Statistics: {Path.Combine(outputPath, statsFileName)}");
Console.WriteLine($"Timeline: {Path.Combine(outputPath, fileName)}");
Console.WriteLine();
Console.WriteLine(string.Join(Environment.NewLine, BossSummary.Create(models.ToList())));
});
}

public void ParseLogsFromDpsReport(string? day, bool reverse, bool killOnly, bool filter,
CancellationToken cancellationToken)
{
Expand Down
Loading