Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for longer --publication-period (5/10 years) #201

Merged
merged 1 commit into from
Nov 12, 2023
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
2 changes: 1 addition & 1 deletion Solutions/Stacker.Cli/Commands/FacebookBufferCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class Settings : CommandSettings
public bool Randomise { get; set; }

[CommandOption("-p|--publication-period")]
[Description("Publication period to filter content items by. <LastMonth|LastWeek|LastYear|None|ThisMonth|ThisWeek|ThisYear> If specified --from-date and --to-date are ignored.")]
[Description("Publication period to filter content items by. <LastMonth|LastWeek|LastYear|LastFiveYears|LastTenYears|None|ThisMonth|ThisWeek|ThisYear> If specified --from-date and --to-date are ignored.")]
public PublicationPeriod PublicationPeriod { get; init; }

[CommandOption("-f|--from-date")]
Expand Down
2 changes: 1 addition & 1 deletion Solutions/Stacker.Cli/Commands/LinkedInBufferCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class Settings : CommandSettings
public bool Randomise { get; set; }

[CommandOption("-p|--publication-period")]
[Description("Publication period to filter content items by. <LastMonth|LastWeek|LastYear|None|ThisMonth|ThisWeek|ThisYear> If specified --from-date and --to-date are ignored.")]
[Description("Publication period to filter content items by. <LastMonth|LastWeek|LastYear|LastFiveYears|LastTenYears|None|ThisMonth|ThisWeek|ThisYear> If specified --from-date and --to-date are ignored.")]
public PublicationPeriod PublicationPeriod { get; init; }

[CommandOption("-f|--from-date")]
Expand Down
2 changes: 1 addition & 1 deletion Solutions/Stacker.Cli/Commands/TwitterBufferCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class Settings : CommandSettings
public bool Randomise { get; set; }

[CommandOption("-p|--publication-period")]
[Description("Publication period to filter content items by. <LastMonth|LastWeek|LastYear|None|ThisMonth|ThisWeek|ThisYear> If specified --from-date and --to-date are ignored.")]
[Description("Publication period to filter content items by. <LastMonth|LastWeek|LastYear|LastFiveYears|LastTenYears|None|ThisMonth|ThisWeek|ThisYear> If specified --from-date and --to-date are ignored.")]
public PublicationPeriod PublicationPeriod { get; init; }

[CommandOption("-f|--from-date")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ public DateInterval Convert(PublicationPeriod publicationPeriod)
LocalDate startOfLastYear = LocalDate.FromDateTime(new DateTime(today.Year, 1, 1)).PlusYears(-1);
LocalDate endOfLastYear = LocalDate.FromDateTime(new DateTime(today.Year, 12, 31)).PlusYears(-1);
return new DateInterval(startOfLastYear, endOfLastYear);
case PublicationPeriod.LastFiveYears:
LocalDate startOfLastFiveYears = LocalDate.FromDateTime(new DateTime(today.Year, 1, 1)).PlusYears(-5);
LocalDate endOfLastFiveYears = LocalDate.FromDateTime(new DateTime(today.Year, 12, 31)).PlusYears(-1);
return new DateInterval(startOfLastFiveYears, endOfLastFiveYears);
case PublicationPeriod.LastTenYears:
LocalDate startOfLastTenYears = LocalDate.FromDateTime(new DateTime(today.Year, 1, 1)).PlusYears(-10);
LocalDate endOfLastTenYears = LocalDate.FromDateTime(new DateTime(today.Year, 12, 31)).PlusYears(-1);
return new DateInterval(startOfLastTenYears, endOfLastTenYears);
default:
throw new ArgumentOutOfRangeException(nameof(publicationPeriod), publicationPeriod, null);
}
Expand Down
12 changes: 11 additions & 1 deletion Solutions/Stacker.Cli/Domain/Publication/PublicationPeriod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ public enum PublicationPeriod
ThisYear,

/// <summary>
/// Filter ContentItems with PublishedOn dates last year.
/// Filter ContentItems with PublishedOn dates within the last year.
/// </summary>
LastYear,

/// <summary>
/// Filter ContentItems with PublishedOn dates within the last 5 years.
/// </summary>
LastFiveYears,

/// <summary>
/// Filter ContentItems with PublishedOn dates within the last 10 years.
/// </summary>
LastTenYears,
}