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

feat: Add support for the new Pre-Translate Efficiency Report #65

27 changes: 27 additions & 0 deletions crowdin/model/reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const (
ReportTransactionCostsPostEditing ReportName = "translation-costs-pe"
ReportContributionRawData ReportName = "contribution-raw-data"
ReportTopMembers ReportName = "top-members"
ReportPreTranslateEfficiency ReportName = "pre-translate-efficiency"

// Organization reports.
ReportGroupTranslationCostsPostEditing ReportName = "group-translation-costs-pe"
Expand Down Expand Up @@ -200,6 +201,7 @@ type ReportGenerateRequest struct {
// - TransactionCostsPostEditingSchema
// - TopMembersSchema
// - ContributionRawDataSchema
// - PreTranslateEfficiencySchema
Schema ReportSchema `json:"schema"`
}

Expand Down Expand Up @@ -361,6 +363,25 @@ type (
// Report date to in UTC, ISO 8601.
DateTo string `json:"dateTo,omitempty"`
}

// PreTranslateEfficiencySchema defines the schema for pre translate
// efficiency report.
PreTranslateEfficiencySchema struct {
// Report unit. Enum: strings, words, chars, chars_with_spaces.
// Default: words.
Unit ReportUnit `json:"unit,omitempty"`
// Export file format.
// Enum: xlsx, csv, json. Default: xlsx.
Format ReportFormat `json:"format,omitempty"`
// Split into categories by edit distance.
PostEditingCategories []string `json:"postEditingCategories,omitempty"`
// Language Identifier for which the report should be generated.
LanguageID string `json:"languageId,omitempty"`
// Report date from in UTC, ISO 8601.
DateFrom string `json:"dateFrom,omitempty"`
// Report date to in UTC, ISO 8601.
DateTo string `json:"dateTo,omitempty"`
}
)

// Validate checks if the request is valid.
Expand Down Expand Up @@ -407,6 +428,12 @@ func (r *ContributionRawDataSchema) ValidateSchema() error {
return nil
}

// ValidateSchema implements the ReportSchema interface and checks if the
// PreTranslateEfficiency schema is valid.
func (r *PreTranslateEfficiencySchema) ValidateSchema() error {
return nil
}

// GroupReportGenerateRequest defines the structure of a request to
// generate a group or organization report.
type GroupReportGenerateRequest struct {
Expand Down
9 changes: 9 additions & 0 deletions crowdin/model/reports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ func TestReportGenerateRequestValidate(t *testing.T) {
},
valid: true,
},
{
name: "valid schema (ReportPreTranslateEfficiencySchema)",
req: &ReportGenerateRequest{
Name: ReportPreTranslateEfficiency,
Schema: &PreTranslateEfficiencySchema{Unit: ReportUnitStrings, PostEditingCategories: []string{"0-10"}},
},
valid: true,
},
// TODO: add any negative cases?
}

for _, tt := range tests {
Expand Down