Skip to content

Commit

Permalink
refactor constants to fix codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
rekolobov committed Jul 26, 2021
1 parent 528356e commit 7b97af4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
23 changes: 11 additions & 12 deletions src/YouTrackSharp/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,43 @@ public static class FieldsQueryStrings
/// <summary>
/// Fields query for activities resource.
/// </summary>
public static string ACTIVITIES =
"$type,added($type,agile(id),attachments($type,author(fullName,id,ringId),comment(id),created,id,imageDimensions(height,width),issue(id,project(id,ringId)),mimeType,name,removed,size,thumbnailURL,url,visibility($type,implicitPermittedUsers($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),permittedGroups($type,allUsersGroup,icon,id,name,ringId),permittedUsers($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId))),author($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),color(id),commands(end,errorText,hasError,start),comment(id),created,creator($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),date,deleted,duration(id,minutes,presentation),fetched,files,hasEmail,id,idReadable,isDraft,isLocked,issue(id,project(id,ringId)),localizedName,mimeType,minutes,name,noHubUserReason(id),noUserReason(id),numberInProject,presentation,processors($type,id),project($type,id,isDemo,leader(id),name,plugins(timeTrackingSettings(enabled,estimate(field(id,name),id),timeSpent(field(id,name),id)),vcsIntegrationSettings(processors(enabled,migrationFailed,server(enabled,url),upsourceHubResourceKey,url))),ringId,shortName),reaction,reactionOrder,reactions(author($type,fullName,id,isLocked),id,reaction),removed,reopened,resolved,shortName,size,state(id),summary,text,textPreview,thumbnailURL,type(id,name),url,urls,user($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),userName,usesMarkdown,version,visibility($type,implicitPermittedUsers($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),permittedGroups($type,allUsersGroup,icon,id,name,ringId),permittedUsers($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId))),author($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),authorGroup(icon,name),category(id),field($type,customField(fieldType(isMultiValue,valueType),id),id,linkId,presentation),id,markup,pullRequest(author($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),date,fetched,files,id,idExternal,noHubUserReason(id),noUserReason(id),textPreview,titlePreview,url,user($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),userName),removed($type,agile(id),color(id),id,idReadable,isDraft,isLocked,localizedName,name,numberInProject,project($type,id,isDemo,leader(id),name,plugins(timeTrackingSettings(enabled,estimate(field(id,name),id),timeSpent(field(id,name),id)),vcsIntegrationSettings(processors(enabled,migrationFailed,server(enabled,url),upsourceHubResourceKey,url))),ringId,shortName),reaction,resolved,state(id),summary,text),target(created,id,usesMarkdown),targetMember,targetSubMember,timestamp,type";
public const string Activities = "$type,added($type,agile(id),attachments($type,author(fullName,id,ringId),comment(id),created,id,imageDimensions(height,width),issue(id,project(id,ringId)),mimeType,name,removed,size,thumbnailURL,url,visibility($type,implicitPermittedUsers($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),permittedGroups($type,allUsersGroup,icon,id,name,ringId),permittedUsers($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId))),author($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),color(id),commands(end,errorText,hasError,start),comment(id),created,creator($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),date,deleted,duration(id,minutes,presentation),fetched,files,hasEmail,id,idReadable,isDraft,isLocked,issue(id,project(id,ringId)),localizedName,mimeType,minutes,name,noHubUserReason(id),noUserReason(id),numberInProject,presentation,processors($type,id),project($type,id,isDemo,leader(id),name,plugins(timeTrackingSettings(enabled,estimate(field(id,name),id),timeSpent(field(id,name),id)),vcsIntegrationSettings(processors(enabled,migrationFailed,server(enabled,url),upsourceHubResourceKey,url))),ringId,shortName),reaction,reactionOrder,reactions(author($type,fullName,id,isLocked),id,reaction),removed,reopened,resolved,shortName,size,state(id),summary,text,textPreview,thumbnailURL,type(id,name),url,urls,user($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),userName,usesMarkdown,version,visibility($type,implicitPermittedUsers($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),permittedGroups($type,allUsersGroup,icon,id,name,ringId),permittedUsers($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId))),author($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),authorGroup(icon,name),category(id),field($type,customField(fieldType(isMultiValue,valueType),id),id,linkId,presentation),id,markup,pullRequest(author($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),date,fetched,files,id,idExternal,noHubUserReason(id),noUserReason(id),textPreview,titlePreview,url,user($type,avatarUrl,email,fullName,id,isLocked,issueRelatedGroup(icon),login,name,online,profiles(general(trackOnlineStatus)),ringId),userName),removed($type,agile(id),color(id),id,idReadable,isDraft,isLocked,localizedName,name,numberInProject,project($type,id,isDemo,leader(id),name,plugins(timeTrackingSettings(enabled,estimate(field(id,name),id),timeSpent(field(id,name),id)),vcsIntegrationSettings(processors(enabled,migrationFailed,server(enabled,url),upsourceHubResourceKey,url))),ringId,shortName),reaction,resolved,state(id),summary,text),target(created,id,usesMarkdown),targetMember,targetSubMember,timestamp,type";

/// <summary>
/// Fields query for attachments (sub)resource.
/// </summary>
public static string ATTACHMENTS =
public const string Attachments =
"id,url,name,author(login),visibility(permittedGroups(name)),created";

/// <summary>
/// Fields query for comments (sub)resource.
/// </summary>
public static string COMMENTS =
public const string Comments =
"id,author(id,login,fullName),issue(idReadable),deleted,usesMarkdown,text,textPreview,created,updated,visibility(permittedGroups(name))";

private static string ISSUES_FIELD_DESCRIPTION = "description";
private const string IssuesFieldDescription = "description";

private static string ISSUES_FIELD_WIKIFIED_DESCRIPTION = "wikifiedDescription";
private const string IssuesFieldWikifiedDescription = "wikifiedDescription";

/// <summary>
/// Fields query for links (sub)resource.
/// </summary>
public static string ISSUE_LINKS =
public const string IssueLinks =
"direction,linkType(name,targetToSource,localizedTargetToSource,sourceToTarget,localizedSourceToTarget),issues(id,idReadable)";

private static string ISSUES_FIELDS_NO_DESCRIPTION = "comments(" + COMMENTS + "),links(" + ISSUE_LINKS +
"),attachments(" + ATTACHMENTS +
"),id,idReadable,externalIssue(id),project(id,name,shortName),usesMarkdown,reporter(id,login,fullName),created,updated,resolved,votes,watchers(hasStar),numberInProject,updater(id,login,fullName),commentsCount,summary,tags(id,name),customFields(id,name,value(id,name,fullName,localizedName,text,markdownText,login,minutes,color(id,background,foreground))),visibility(permittedGroups(id,name))";
private const string IssuesFieldsNoDescription = "comments(" + Comments + "),links(" + IssueLinks +
"),attachments(" + Attachments +
"),id,idReadable,externalIssue(id),project(id,name,shortName),usesMarkdown,reporter(id,login,fullName),created,updated,resolved,votes,watchers(hasStar),numberInProject,updater(id,login,fullName),commentsCount,summary,tags(id,name),customFields(id,name,value(id,name,fullName,localizedName,text,markdownText,login,minutes,color(id,background,foreground))),visibility(permittedGroups(id,name))";

/// <summary>
/// Fields query for issues resource with issue description wikified.
/// </summary>
public static string ISSUES_WIKIFIED = ISSUES_FIELD_WIKIFIED_DESCRIPTION + "," + ISSUES_FIELDS_NO_DESCRIPTION;
public const string IssuesWikified = IssuesFieldWikifiedDescription + "," + IssuesFieldsNoDescription;

/// <summary>
/// Fields query for issues resource with issue description not wikified.
/// </summary>
public static string ISSUES_NOT_WIKIFIED = ISSUES_FIELD_DESCRIPTION + "," + ISSUES_FIELDS_NO_DESCRIPTION;
public const string IssuesNotWikified = IssuesFieldDescription + "," + IssuesFieldsNoDescription;
}
}
}
2 changes: 1 addition & 1 deletion src/YouTrackSharp/Issues/IssuesService.Attachments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public async Task<IEnumerable<Attachment>> GetAttachmentsForIssue(string issueId

var client = await _connection.GetAuthenticatedApiClient();
var response =
await client.IssuesAttachmentsGetAsync(issueId, Constants.FieldsQueryStrings.ATTACHMENTS, 0, -1);
await client.IssuesAttachmentsGetAsync(issueId, Constants.FieldsQueryStrings.Attachments, 0, -1);

return response.Select(Attachment.FromApiEntity);
}
Expand Down
2 changes: 1 addition & 1 deletion src/YouTrackSharp/Issues/IssuesService.Comments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task<IEnumerable<Comment>> GetCommentsForIssue(string issueId, bool
}

var client = await _connection.GetAuthenticatedApiClient();
var response = await client.IssuesCommentsGetAsync(issueId, Constants.FieldsQueryStrings.COMMENTS, 0, -1);
var response = await client.IssuesCommentsGetAsync(issueId, Constants.FieldsQueryStrings.Comments, 0, -1);

return response.Select(comment => Comment.FromApiEntity(comment, wikifyDescription));
}
Expand Down
2 changes: 1 addition & 1 deletion src/YouTrackSharp/Issues/IssuesService.History.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task<IEnumerable<Change>> GetChangeHistoryForIssue(string issueId)

var client = await _connection.GetAuthenticatedApiClient();
var response = await client.IssuesActivitiesGetAsync(issueId,
ACTIVITIES_CATEGORIES, false, null, null, null, Constants.FieldsQueryStrings.ACTIVITIES);
ACTIVITIES_CATEGORIES, false, null, null, null, Constants.FieldsQueryStrings.Activities);

return response.Select(Change.FromApiEntity).ToList();
}
Expand Down
2 changes: 1 addition & 1 deletion src/YouTrackSharp/Issues/IssuesService.Querying.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<ICollection<Issue>> GetIssues(string filter = null, int? skip
{
var client = await _connection.GetAuthenticatedApiClient();
var response = await client.IssuesGetAsync(filter,
wikifyDescription ? Constants.FieldsQueryStrings.ISSUES_WIKIFIED : Constants.FieldsQueryStrings.ISSUES_NOT_WIKIFIED,
wikifyDescription ? Constants.FieldsQueryStrings.IssuesWikified : Constants.FieldsQueryStrings.IssuesNotWikified,
skip, take);

return response.Select(issue => Issue.FromApiEntity(issue, wikifyDescription, wikifyContents)).ToList();
Expand Down
4 changes: 2 additions & 2 deletions src/YouTrackSharp/Issues/IssuesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task<Issue> GetIssue(string issueId, bool wikifyDescription = false
try
{
var response = await client.IssuesGetAsync(issueId,
wikifyDescription ? Constants.FieldsQueryStrings.ISSUES_WIKIFIED : Constants.FieldsQueryStrings.ISSUES_NOT_WIKIFIED,
wikifyDescription ? Constants.FieldsQueryStrings.IssuesWikified : Constants.FieldsQueryStrings.IssuesNotWikified,
default(System.Threading.CancellationToken));
return Issue.FromApiEntity(response, wikifyDescription, wikifyContents);
}
Expand Down Expand Up @@ -261,7 +261,7 @@ public async Task<IEnumerable<Link>> GetLinksForIssue(string issueId)
}

var client = await _connection.GetAuthenticatedApiClient();
var response = await client.IssuesLinksGetAsync(issueId, Constants.FieldsQueryStrings.ISSUE_LINKS, 0, -1);
var response = await client.IssuesLinksGetAsync(issueId, Constants.FieldsQueryStrings.IssueLinks, 0, -1);

return Link.FromApiEntities(response, issueId);
}
Expand Down

0 comments on commit 7b97af4

Please sign in to comment.