Rally C#技术问询:如何统计指定版本下负责人处理的特性数量?
Automate Rally Feature Stats by Version & Owner with C# SDK
Got it, let's tackle this problem of replacing your manual Rally report extraction with code using the C# SDK. This solution will automatically count features per specified version, break down ownership by your dev team, and track statuses like completed/blocked—exactly matching the manual report you're pulling now.
Prerequisite
First, make sure you've installed the Rally C# SDK via NuGet: search for Rally.RestApi and add it to your project. You'll also need an API key from Rally (generate one in your account settings) and the ref IDs for your workspace/project (find these in the URL when you navigate to them in Rally).
Full Code Implementation
using System; using System.Collections.Generic; using System.Linq; using Rally.RestApi; using Rally.RestApi.Response; class RallyFeatureTracker { static void Main(string[] args) { // Replace these with your actual Rally details const string RallyUrl = "https://rally1.rallydev.com"; const string ApiKey = "your-rally-api-key-here"; const string WorkspaceRef = "/workspace/123456789"; // Grab from Rally URL const string ProjectRef = "/project/987654321"; // Grab from Rally URL // Initialize the API client (using 'using' ensures clean connection disposal) using var restApi = new RallyRestApi(ApiKey, RallyUrl); restApi.SetWorkspace(WorkspaceRef); restApi.SetProject(ProjectRef); // List of versions you want to generate reports for var targetVersions = new List<string> { "Q2-1", "Q1-2" }; foreach (var version in targetVersions) { Console.WriteLine($"=== {version} Feature Statistics ==="); // Build query to fetch all features linked to the target version var featureQuery = new Query("Feature") { Fetch = new List<string> { "Owner", "State", "Release" }, QueryString = $"Release.Name = \"{version}\"" }; var queryResults = restApi.Query(featureQuery); if (queryResults.TotalResultCount == 0) { Console.WriteLine("No features found for this version.\n"); continue; } // Total features in the version int totalFeatures = queryResults.TotalResultCount; Console.WriteLine($"Total features in version: {totalFeatures}"); // Filter features assigned to your dev team (adjust the username filter to match your team) var devTeamFeatures = queryResults.Results .Where(f => f["Owner"] != null && ((DynamicJsonObject)f["Owner"])["UserName"].Contains("your-dev-team-username-pattern")); int devTeamFeatureCount = devTeamFeatures.Count(); Console.WriteLine($"- {devTeamFeatureCount} features assigned to the dev team"); // Break down dev team features by status int completedCount = devTeamFeatures.Count(f => f["State"].ToString() == "Completed"); Console.WriteLine($" - {completedCount} completed"); int blockedCount = devTeamFeatures.Count(f => f["State"].ToString() == "Blocked"); if (blockedCount > 0) { Console.WriteLine($" - {blockedCount} blocked (awaiting further info)"); } // Calculate unassigned/pending features int unassignedOrPending = totalFeatures - devTeamFeatureCount; Console.WriteLine($"- {unassignedOrPending} features unassigned/awaiting further research\n"); // Add Q1-2 specific note to match your manual report if (version == "Q1-2") { Console.WriteLine("Additional note: The team has completed all assigned deliverable features for this version.\n"); } } } }
Key Customizations You Need to Make
- Rally Connection Details: Swap out the placeholder values for
ApiKey,WorkspaceRef, andProjectRefwith your actual Rally credentials and IDs (you can grab the ref IDs from the URL bar when navigating to your workspace/project in Rally). - Dev Team Filter: Adjust the
UserName.Contains()check to match your dev team's usernames. If you have a fixed list of team members, you could use an exact match like:var devTeamUsernames = new List<string> { "dev1@yourcompany.com", "dev2@yourcompany.com" }; var devTeamFeatures = queryResults.Results .Where(f => f["Owner"] != null && devTeamUsernames.Contains(((DynamicJsonObject)f["Owner"])["UserName"].ToString())); - Status Values: Double-check that the
Statevalues (like "Completed" or "Blocked") match what's used in your Rally instance—some teams use "Done" instead of "Completed", so tweak this if needed. - Q1-2 Custom Note: Modify the additional note to match your actual team's completion status as required.
How This Replaces Your Manual Work
- The code connects to Rally, pulls all features tied to your target versions, and automatically groups them by owner and status.
- It replicates exactly the breakdown you're doing manually: total features, dev team-assigned count, completed/blocked statuses, and unassigned/pending counts.
- Using
usingfor the API client ensures the connection is cleaned up properly after running, so you don't have to worry about lingering connections.
内容的提问来源于stack exchange,提问作者Aswin Francis
相关产品推荐
相关产品推荐

