Skip to content

Commit

Permalink
Implement last_activity_after and last_activity_before filters Introd…
Browse files Browse the repository at this point in the history
…uced in Gitlab Version 12.10 (#140)

Co-authored-by: Sudheesh PM <[email protected]>
Co-authored-by: Joseph Petersen <[email protected]>
  • Loading branch information
3 people authored May 30, 2020
1 parent 15d4adf commit f129f88
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/GitLabApiClient/Internal/Queries/ProjectsQueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ protected override void BuildCore(Query query, ProjectQueryOptions options)

if (options.WithMergeRequestsEnabled)
query.Add("with_merge_requests_enabled", options.WithMergeRequestsEnabled);

if (options.LastActivityAfter.Year != 0001) //Not Default year
query.Add("last_activity_after", options.LastActivityAfter.ToUniversalTime().ToString("o")); //Format: ISO 8601 YYYY-MM-DDTHH:MM:SSZ

if (options.LastActivityBefore.Year != 0001) //Not Default year
query.Add("last_activity_before", options.LastActivityBefore.ToUniversalTime().ToString("o")); //Format: ISO 8601 YYYY-MM-DDTHH:MM:SSZ
}

private static string GetProjectOrderQueryValue(ProjectsOrder order)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;

namespace GitLabApiClient.Models.Projects.Requests
{
/// <summary>
Expand Down Expand Up @@ -71,5 +73,17 @@ internal ProjectQueryOptions() { }
/// Limit by enabled merge requests feature
/// </summary>
public bool WithMergeRequestsEnabled { get; set; }

/// <summary>
/// Limit by Last Activity After specified datetime
/// Note: You would need GitLab 12.10 or later
/// </summary>
public DateTime LastActivityAfter { get; set; }

/// <summary>
/// Limit by Last Activity Before specified datetime
/// Note: You would need GitLab 12.10 or later
/// </summary>
public DateTime LastActivityBefore { get; set; }
}
}

0 comments on commit f129f88

Please sign in to comment.