-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
294 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using Apps.XTM.Constants; | ||
using Apps.XTM.Invocables; | ||
using Apps.XTM.Models.Request; | ||
using Apps.XTM.Models.Response; | ||
using Apps.XTM.Models.Response.Customers; | ||
using Blackbird.Applications.Sdk.Common.Actions; | ||
using Blackbird.Applications.Sdk.Common.Invocation; | ||
using DocumentFormat.OpenXml.Bibliography; | ||
using RestSharp; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Apps.XTM.Actions | ||
{ | ||
[ActionList] | ||
public class LqaActions : XtmInvocable | ||
{ | ||
public LqaActions(InvocationContext invocationContext) : base(invocationContext) | ||
{ | ||
} | ||
|
||
[Action("Search LQA reports", Description = "Define criteria to search LQA reports")] | ||
public async Task<List<LqaResponse>> SearchLqa(LQARequest input) | ||
{ | ||
var Params = new List<string>(); | ||
if (input.DateFrom is not null) Params.Add($"completeDateFrom={input.DateFrom:yyyy-MM-dd}"); | ||
if (input.DateTo is not null) Params.Add($"completeDateTo={input.DateTo:yyyy-MM-dd}"); | ||
if (input.TargetLangs is not null) Params.Add($"targetLanguages={String.Join(",",input.TargetLangs)}"); | ||
if (input.Type is not null) Params.Add($"type={input.Type}"); | ||
|
||
var endpoint = $"{ApiEndpoints.Projects}/lqa/download"; | ||
if (Params is not null && Params.Count > 0) | ||
{ endpoint = endpoint + "?"+String.Join("&",Params); } | ||
|
||
var response = await Client.ExecuteXtmWithJson<List<LqaResponse>>(endpoint, | ||
Method.Get, | ||
null, | ||
Creds); | ||
|
||
return FixDate(response); | ||
} | ||
|
||
private List<LqaResponse> FixDate(List<LqaResponse> response) | ||
{ | ||
var updated = new List<LqaResponse>(); | ||
foreach (var item in response) | ||
{ | ||
|
||
updated.Add(new LqaResponse | ||
{ | ||
id = item.id, | ||
evaluator = item.evaluator, | ||
project = item.project, | ||
customer = item.customer, | ||
language = item.language, | ||
evaluee = item.evaluee, | ||
files = item.files, | ||
severityMultipliers = item.severityMultipliers, | ||
completeDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(long.Parse(item.completeDate)).ToString("yyyy-MM-dd") | ||
}); | ||
} | ||
|
||
return updated; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Apps.XTM/DataSourceHandlers/EnumHandlers/LqaTypeDataHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Blackbird.Applications.Sdk.Utils.Sdk.DataSourceHandlers; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Apps.XTM.DataSourceHandlers.EnumHandlers | ||
{ | ||
public class LqaTypeDataHandler : EnumDataHandler | ||
{ | ||
protected override Dictionary<string, string> EnumValues => new() | ||
{ | ||
{"LANGUAGE", "Language"}, | ||
{"FILE", "File"} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
| ||
|
||
using Apps.XTM.DataSourceHandlers.EnumHandlers; | ||
using Blackbird.Applications.Sdk.Common; | ||
using Blackbird.Applications.Sdk.Common.Dynamic; | ||
|
||
namespace Apps.XTM.Models.Request | ||
{ | ||
public class LQARequest | ||
{ | ||
[Display("Date from")] | ||
public DateTime? DateFrom { get; set; } | ||
|
||
[Display("Date to")] | ||
public DateTime? DateTo { get; set; } | ||
|
||
[DataSource(typeof(LanguageDataHandler))] | ||
[Display("Target languages")] | ||
public List<string>? TargetLangs { get; set; } | ||
|
||
[DataSource(typeof(LqaTypeDataHandler))] | ||
[Display("LQA type")] | ||
public string? Type { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
| ||
|
||
using Blackbird.Applications.Sdk.Common; | ||
|
||
namespace Apps.XTM.Models.Response | ||
{ | ||
public class LqaResponse | ||
{ | ||
[Display("LQA report ID")] | ||
public string id { get; set; } | ||
|
||
[Display("Severity multipliers")] | ||
public SeverityMultipliers severityMultipliers { get; set; } | ||
|
||
[Display("Completion date")] | ||
public string completeDate { get; set; } | ||
|
||
[Display("Evaluee")] | ||
public Evaluee evaluee { get; set; } | ||
|
||
[Display("Evaluator")] | ||
public Evaluator evaluator { get; set; } | ||
|
||
[Display("Customer")] | ||
public Customer customer { get; set; } | ||
|
||
[Display("Project")] | ||
public Project project { get; set; } | ||
|
||
[Display("Language")] | ||
public Language language { get; set; } | ||
|
||
[Display("Files")] | ||
public List<File>? files { get; set; } | ||
} | ||
public class Customer | ||
{ | ||
[Display("Customer ID")] | ||
public int id { get; set; } | ||
|
||
[Display("Customer name")] | ||
public string name { get; set; } | ||
} | ||
|
||
public class Error | ||
{ | ||
[Display("Error ID")] | ||
public string id { get; set; } | ||
|
||
[Display("Parent ID")] | ||
public string parentId { get; set; } | ||
|
||
[Display("Parent Path")] | ||
public string parentPath { get; set; } | ||
|
||
[Display("Key")] | ||
public string key { get; set; } | ||
|
||
[Display("Weight")] | ||
public string weight { get; set; } | ||
|
||
[Display("Issue count")] | ||
public IssueCounts issueCounts { get; set; } | ||
|
||
[Display("Penalty")] | ||
public Penalty penalty { get; set; } | ||
|
||
[Display("Target subscore")] | ||
public string targetSubscore { get; set; } | ||
} | ||
|
||
public class Evaluator | ||
{ | ||
[Display("Evaluator ID")] | ||
public int userId { get; set; } | ||
|
||
[Display("Evaluator Name")] | ||
public string userName { get; set; } | ||
} | ||
|
||
public class Evaluee | ||
{ | ||
[Display("Evaluaee ID")] | ||
public int userId { get; set; } | ||
|
||
[Display("Evaluaee name")] | ||
public string userName { get; set; } | ||
} | ||
|
||
public class File | ||
{ | ||
public _File file { get; set; } | ||
|
||
[Display("Job ID")] | ||
public int jobId { get; set; } | ||
|
||
[Display("Word count")] | ||
public int wordCount { get; set; } | ||
public Total total { get; set; } | ||
public List<Error> errors { get; set; } | ||
} | ||
|
||
public class _File | ||
{ | ||
[Display("File ID")] | ||
public int fileId { get; set; } | ||
|
||
[Display("File name")] | ||
public string fileName { get; set; } | ||
} | ||
|
||
public class IssueCounts | ||
{ | ||
public int Neutral { get; set; } | ||
public int Minor { get; set; } | ||
public int Major { get; set; } | ||
public int Critical { get; set; } | ||
} | ||
|
||
public class Language | ||
{ | ||
[Display("Language code")] | ||
public string code { get; set; } | ||
|
||
[Display("Word count")] | ||
public int wordCount { get; set; } | ||
public Total Total { get; set; } | ||
public List<Error> Errors { get; set; } | ||
} | ||
|
||
public class Penalty | ||
{ | ||
public string Raw { get; set; } | ||
|
||
[Display("Adjusted")] | ||
public string adj { get; set; } | ||
} | ||
|
||
public class Project | ||
{ | ||
[Display("Project ID")] | ||
public int id { get; set; } | ||
|
||
[Display("Project name")] | ||
public string name { get; set; } | ||
|
||
[Display("Subject Matter")] | ||
public SubjectMatter subjectMatter { get; set; } | ||
|
||
[Display("Word count")] | ||
public int wordCount { get; set; } | ||
public Total Total { get; set; } | ||
public List<Error> Errors { get; set; } | ||
} | ||
|
||
public class SeverityMultipliers | ||
{ | ||
public string Neutral { get; set; } | ||
public string Minor { get; set; } | ||
public string Major { get; set; } | ||
public string Critical { get; set; } | ||
} | ||
|
||
public class SubjectMatter | ||
{ | ||
[Display("Subject matter ID")] | ||
public int id { get; set; } | ||
public string Name { get; set; } | ||
} | ||
|
||
public class Total | ||
{ | ||
public string Weight { get; set; } | ||
|
||
[Display("Issue count")] | ||
public IssueCounts issueCounts { get; set; } | ||
public Penalty Penalty { get; set; } | ||
|
||
[Display("Target subscore")] | ||
public string targetSubscore { get; set; } | ||
} | ||
} |