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

Simplify the Aggregation type #32

Closed
shaunsales opened this issue Sep 3, 2020 · 2 comments
Closed

Simplify the Aggregation type #32

shaunsales opened this issue Sep 3, 2020 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@shaunsales
Copy link
Contributor

Working with the Aggregation type is currently not as easy as it could be. We can avoid creating a new object, and the ambiguity with the Aggregation.Name property (easy to confuse when comparing).

I propose we convert it to an enum, which will be easier for the end user;

public enum Aggregation
{
	Avg,
	Sum,
	Min,
	Max,
	Range,
	Count,
	First,
	Last,
	StdP,
	StdS,
	VarP,
	VarS,
}

And internally use an extension method to retrieve the RedisTimeSeries param;

internal static class AggregationExtensions
{
	public static string Param(this Aggregation aggregation) => aggregation switch
	{
		Aggregation.Avg => "avg",
		Aggregation.Sum => "sum",
		Aggregation.Min => "min",
		Aggregation.Max => "max",
		Aggregation.Range => "range",
		Aggregation.Count => "count",
		Aggregation.First => "first",
		Aggregation.Last => "last",
		Aggregation.StdP => "std.p",
		Aggregation.StdS => "std.s",
		Aggregation.VarP => "var.p",
		Aggregation.VarS => "var.s",
		_ => throw new ArgumentException("Invalid Aggregation parameter"),
	};
}
@DvirDukhan DvirDukhan added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Sep 3, 2020
@DvirDukhan
Copy link
Collaborator

@shaunsales thanks, good point

@ashtul @filipecosta90 good first issue

@DvirDukhan
Copy link
Collaborator

closed by #36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants