Skip to content

Commit

Permalink
refactor(reports): 🚚 rename view -> reports (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNZL committed May 18, 2023
1 parent a8bd335 commit e28ffca
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 71 deletions.
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion src/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
Settings.StopCommand => await this._togglTrack.RequestStopEntry(token, query),
Settings.DeleteCommand => await this._togglTrack.RequestDeleteEntry(token),
Settings.ContinueCommand => await this._togglTrack.RequestContinueEntry(token, query),
Settings.ViewCommand => await this._togglTrack.RequestViewReports(token, query),
Settings.ReportsCommand => await this._togglTrack.RequestViewReports(token, query),
_ => (await this._togglTrack.GetDefaultHotKeys())
.FindAll(result =>
{
Expand Down
50 changes: 25 additions & 25 deletions src/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ public class Settings
internal const string StopCommand = "stop";
internal const string DeleteCommand = "delete";
internal const string ContinueCommand = "continue";
internal const string ViewCommand = "view";
internal const string ReportsCommand = "reports";
internal const string BrowserCommand = "browser";
internal const string RefreshCommand = "refresh";

internal const string EditProjectFlag = "-p";
internal const string TimeSpanFlag = "-t";

internal enum ViewSpanKeys
internal enum ReportsSpanKeys
{
Day,
Week,
Month,
Year,
}
internal static readonly List<ViewSpanCommandArgument> ViewSpanArguments = new List<ViewSpanCommandArgument>
internal static readonly List<ReportsSpanCommandArgument> ReportsSpanArguments = new List<ReportsSpanCommandArgument>
{
new ViewSpanCommandArgument
new ReportsSpanCommandArgument
{
Argument = "day",
Interpolation = "today",
Expand All @@ -38,7 +38,7 @@ internal enum ViewSpanKeys
Start = now => now,
End = now => now,
},
new ViewSpanCommandArgument
new ReportsSpanCommandArgument
{
Argument = "week",
Interpolation = "this week",
Expand All @@ -48,7 +48,7 @@ internal enum ViewSpanKeys
// Sunday of the current week
End = now => now.AddDays(-(int)now.DayOfWeek + 7),
},
new ViewSpanCommandArgument
new ReportsSpanCommandArgument
{
Argument = "month",
Interpolation = "this month",
Expand All @@ -58,7 +58,7 @@ internal enum ViewSpanKeys
// Last day of the current month
End = now => new DateTimeOffset(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.Month), 0, 0, 0, now.Offset),
},
new ViewSpanCommandArgument
new ReportsSpanCommandArgument
{
Argument = "year",
Interpolation = "this year",
Expand All @@ -70,39 +70,39 @@ internal enum ViewSpanKeys
},
};

public enum ViewGroupingKeys
public enum ReportsGroupingKeys
{
Projects,
Clients,
Entries,
}
private const string ViewGroupingProjectsArgument = "projects";
private const string ViewGroupingClientsArgument = "clients";
private const string ViewGroupingEntriesArgument = "entries";
internal static readonly List<ViewGroupingCommandArgument> ViewGroupingArguments = new List<ViewGroupingCommandArgument>
private const string ReportsGroupingProjectsArgument = "projects";
private const string ReportsGroupingClientsArgument = "clients";
private const string ReportsGroupingEntriesArgument = "entries";
internal static readonly List<ReportsGroupingCommandArgument> ReportsGroupingArguments = new List<ReportsGroupingCommandArgument>
{
new ViewGroupingCommandArgument
new ReportsGroupingCommandArgument
{
Argument = Settings.ViewGroupingProjectsArgument,
Argument = Settings.ReportsGroupingProjectsArgument,
Interpolation = "View tracked time grouped by project",
Score = 300,
Grouping = Settings.ViewGroupingKeys.Projects,
Grouping = Settings.ReportsGroupingKeys.Projects,
SubArgument = null,
},
new ViewGroupingCommandArgument
new ReportsGroupingCommandArgument
{
Argument = Settings.ViewGroupingClientsArgument,
Argument = Settings.ReportsGroupingClientsArgument,
Interpolation = "View tracked time grouped by client",
Score = 200,
Grouping = Settings.ViewGroupingKeys.Clients,
SubArgument = Settings.ViewGroupingProjectsArgument,
Grouping = Settings.ReportsGroupingKeys.Clients,
SubArgument = Settings.ReportsGroupingProjectsArgument,
},
new ViewGroupingCommandArgument
new ReportsGroupingCommandArgument
{
Argument = Settings.ViewGroupingEntriesArgument,
Argument = Settings.ReportsGroupingEntriesArgument,
Interpolation = "View tracked time entries",
Score = 100,
Grouping = Settings.ViewGroupingKeys.Entries,
Grouping = Settings.ReportsGroupingKeys.Entries,
SubArgument = null,
},
};
Expand All @@ -122,18 +122,18 @@ public class CommandArgument
#nullable enable
}

public class ViewSpanCommandArgument : CommandArgument
public class ReportsSpanCommandArgument : CommandArgument
{
#nullable disable
public Func<DateTimeOffset, DateTimeOffset> Start { get; init; }
public Func<DateTimeOffset, DateTimeOffset> End { get; init; }
#nullable enable
}

public class ViewGroupingCommandArgument : CommandArgument
public class ReportsGroupingCommandArgument : CommandArgument
{
#nullable disable
public Settings.ViewGroupingKeys Grouping { get; init; }
public Settings.ReportsGroupingKeys Grouping { get; init; }
public string SubArgument { get; init; }
#nullable enable
}
Expand Down
8 changes: 4 additions & 4 deletions src/Toggl/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ public void UpdateToken(string token)
* Reports API
*/

public async Task<SummaryTimeEntry?> GetSummaryTimeEntries(long workspaceId, long userId, Settings.ViewGroupingKeys reportGrouping, DateTimeOffset start, DateTimeOffset? end)
public async Task<SummaryTimeEntry?> GetSummaryTimeEntries(long workspaceId, long userId, Settings.ReportsGroupingKeys reportGrouping, DateTimeOffset start, DateTimeOffset? end)
{
(string grouping, string sub_grouping) = (reportGrouping) switch
{
Settings.ViewGroupingKeys.Projects => ("projects", "time_entries"),
Settings.ViewGroupingKeys.Clients => ("clients", "projects"),
Settings.ViewGroupingKeys.Entries => ("projects", "time_entries"),
Settings.ReportsGroupingKeys.Projects => ("projects", "time_entries"),
Settings.ReportsGroupingKeys.Clients => ("clients", "projects"),
Settings.ReportsGroupingKeys.Entries => ("projects", "time_entries"),
_ => ("projects", "time_entries"),
};

Expand Down
Loading

0 comments on commit e28ffca

Please sign in to comment.