Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 196 additions & 0 deletions crowdin/model/reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,22 @@ const (
ReportTopMembers ReportName = "top-members"
ReportTranslatorAccuracy ReportName = "translator-accuracy"
ReportPreTranslateAccuracy ReportName = "pre-translate-accuracy"
ReportSourceContentUpdates ReportName = "source-content-updates"
ReportProjectMembers ReportName = "project-members"
ReportEditorIssues ReportName = "editor-issues"
ReportQACheckIssues ReportName = "qa-check-issues"
ReportSavingActivity ReportName = "saving-activity"
ReportTranslationActivity ReportName = "translation-activity"

// Deprecated: Use ReportPreTranslateAccuracy instead.
ReportPreTranslateEfficiency ReportName = "pre-translate-efficiency"

// Organization reports.
ReportGroupTranslationCostsPostEditing ReportName = "group-translation-costs-pe"
ReportGroupTopMembers ReportName = "group-top-members"
ReportGroupTaskUsage ReportName = "group-task-usage"
ReportGroupQACheckIssues ReportName = "group-qa-check-issues"
ReportGroupTranslationActivity ReportName = "group-translation-activity"
)

// ReportArchive represents a report archive.
Expand Down Expand Up @@ -208,6 +217,12 @@ type ReportGenerateRequest struct {
// - TranslatorAccuracySchema
// - PreTranslateAccuracySchema
// - PreTranslateEfficiencySchema (Deprecated)
// - SourceContentUpdatesSchema
// - ProjectMembersSchema
// - EditorIssuesSchema
// - QACheckIssuesSchema
// - SavingActivitySchema
// - TranslationActivitySchema
Schema ReportSchema `json:"schema"`
}

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

// SourceContentUpdatesSchema defines the schema for the source content updates report.
SourceContentUpdatesSchema 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"`
// Report date from in UTC, ISO 8601.
DateFrom string `json:"dateFrom,omitempty"`
// Report date to in UTC, ISO 8601.
DateTo string `json:"dateTo,omitempty"`
}

// ProjectMembersSchema defines the schema for the project members report.
ProjectMembersSchema struct {
// Export file format. Enum: xlsx, csv, json. Default: xlsx.
Format ReportFormat `json:"format,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"`
}

// EditorIssuesSchema defines the schema for the editor issues report.
EditorIssuesSchema struct {
// Report date from in UTC, ISO 8601.
DateFrom string `json:"dateFrom,omitempty"`
// Report date to in UTC, ISO 8601.
DateTo string `json:"dateTo,omitempty"`
// Export file format. Enum: xlsx, csv, json. Default: xlsx.
Format ReportFormat `json:"format,omitempty"`
// Issue type filter.
IssueType string `json:"issueType,omitempty"`
}

// QACheckIssuesSchema defines the schema for the QA check issues report.
QACheckIssuesSchema struct {
// Export file format. Enum: xlsx, csv, json. Default: xlsx.
Format ReportFormat `json:"format,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"`
}

// SavingActivitySchema defines the schema for the saving activity report.
SavingActivitySchema struct {
// Report unit. Enum: strings, words, chars, chars_with_spaces. Default: words.
Unit ReportUnit `json:"unit,omitempty"`
// Language Identifier for which the report should be generated.
LanguageID string `json:"languageId,omitempty"`
// Export file format. Enum: xlsx, csv, json. Default: xlsx.
Format ReportFormat `json:"format,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"`
}

// TranslationActivitySchema defines the schema for the translation activity report.
TranslationActivitySchema struct {
// Report unit. Enum: strings, words, chars, chars_with_spaces. Default: words.
Unit ReportUnit `json:"unit,omitempty"`
// Language Identifier for which the report should be generated.
LanguageID string `json:"languageId,omitempty"`
// Export file format. Enum: xlsx, csv, json. Default: xlsx.
Format ReportFormat `json:"format,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 @@ -495,6 +584,42 @@ func (r *PreTranslateEfficiencySchema) ValidateSchema() error {
return nil
}

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

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

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

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

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

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

// GroupReportGenerateRequest defines the structure of a request to
// generate a group or organization report.
type GroupReportGenerateRequest struct {
Expand All @@ -504,6 +629,9 @@ type GroupReportGenerateRequest struct {
// One of the following types:
// - GroupTransactionCostsPostEditingSchema
// - GroupTopMembersSchema
// - GroupTaskUsageSchema
// - GroupQACheckIssuesSchema
// - GroupTranslationActivitySchema
Schema ReportGroupSchema `json:"schema"`
}

Expand All @@ -513,6 +641,9 @@ type GroupReportGenerateRequest struct {
// Schema can be one of the following types:
// - GroupTransactionCostsPostEditingSchema
// - GroupTopMembersSchema
// - GroupTaskUsageSchema
// - GroupQACheckIssuesSchema
// - GroupTranslationActivitySchema
type ReportGroupSchema interface {
ValidateGroupSchema() error
}
Expand Down Expand Up @@ -571,6 +702,56 @@ type (
// Report date to in UTC, ISO 8601.
DateTo string `json:"dateTo,omitempty"`
}

// GroupTaskUsageSchema defines the schema for the group task usage report.
GroupTaskUsageSchema struct {
// Export file format. Enum: xlsx, csv, json. Default: xlsx.
Format ReportFormat `json:"format,omitempty"`
// Report type filter.
Type string `json:"type,omitempty"`
// Project identifiers for which the report should be generated.
ProjectIDs []int `json:"projectIds,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"`
// Group results by the specified attribute.
GroupBy string `json:"groupBy,omitempty"`
// Task type identifier filter.
TypeTasks int `json:"typeTasks,omitempty"`
// Language Identifier for which the report should be generated.
LanguageID string `json:"languageId,omitempty"`
// Task creator identifier filter.
CreatorID int `json:"creatorId,omitempty"`
// Task assignee identifier filter.
AssigneeID int `json:"assigneeId,omitempty"`
}

// GroupQACheckIssuesSchema defines the schema for the group QA check issues report.
GroupQACheckIssuesSchema struct {
// Project identifiers for which the report should be generated.
ProjectIDs []int `json:"projectIds,omitempty"`
// Export file format. Enum: xlsx, csv, json. Default: xlsx.
Format ReportFormat `json:"format,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"`
}

// GroupTranslationActivitySchema defines the schema for the group translation activity report.
GroupTranslationActivitySchema struct {
// Project identifiers for which the report should be generated.
ProjectIDs []int `json:"projectIds,omitempty"`
// 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"`
// 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 @@ -609,6 +790,21 @@ func (r *GroupTopMembersSchema) ValidateGroupSchema() error {
return nil
}

// ValidateGroupSchema checks if the GroupTaskUsage schema is valid.
func (r *GroupTaskUsageSchema) ValidateGroupSchema() error {
return nil
}

// ValidateGroupSchema checks if the GroupQACheckIssues schema is valid.
func (r *GroupQACheckIssuesSchema) ValidateGroupSchema() error {
return nil
}

// ValidateGroupSchema checks if the GroupTranslationActivity schema is valid.
func (r *GroupTranslationActivitySchema) ValidateGroupSchema() error {
return nil
}

// ReportSettingsTemplate represents a report settings template.
type ReportSettingsTemplate struct {
ID int `json:"id"`
Expand Down
66 changes: 66 additions & 0 deletions crowdin/model/reports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,54 @@ func TestReportGenerateRequestValidate(t *testing.T) {
},
valid: true,
},
{
name: "valid schema (ReportSourceContentUpdates)",
req: &ReportGenerateRequest{
Name: ReportSourceContentUpdates,
Schema: &SourceContentUpdatesSchema{Unit: ReportUnitWords},
},
valid: true,
},
{
name: "valid schema (ReportProjectMembers)",
req: &ReportGenerateRequest{
Name: ReportProjectMembers,
Schema: &ProjectMembersSchema{Format: ReportFormatXLSX},
},
valid: true,
},
{
name: "valid schema (ReportEditorIssues)",
req: &ReportGenerateRequest{
Name: ReportEditorIssues,
Schema: &EditorIssuesSchema{IssueType: "general_question"},
},
valid: true,
},
{
name: "valid schema (ReportQACheckIssues)",
req: &ReportGenerateRequest{
Name: ReportQACheckIssues,
Schema: &QACheckIssuesSchema{LanguageID: "ach"},
},
valid: true,
},
{
name: "valid schema (ReportSavingActivity)",
req: &ReportGenerateRequest{
Name: ReportSavingActivity,
Schema: &SavingActivitySchema{LanguageID: "ach", Unit: ReportUnitWords},
},
valid: true,
},
{
name: "valid schema (ReportTranslationActivity)",
req: &ReportGenerateRequest{
Name: ReportTranslationActivity,
Schema: &TranslationActivitySchema{LanguageID: "ach", Unit: ReportUnitWords},
},
valid: true,
},
{
name: "valid schema (TranslatorAccuracySchema)",
req: &ReportGenerateRequest{
Expand Down Expand Up @@ -201,6 +249,24 @@ func TestGroupReportGenerateRequestValidate(t *testing.T) {
Schema: &GroupTopMembersSchema{ProjectIDs: []int{1, 2}, Unit: ReportUnitWords, LanguageID: "uk"}},
valid: true,
},
{
name: "valid request (GroupTaskUsageSchema)",
req: &GroupReportGenerateRequest{Name: ReportGroupTaskUsage,
Schema: &GroupTaskUsageSchema{ProjectIDs: []int{1}, Type: "workload"}},
valid: true,
},
{
name: "valid request (GroupQACheckIssuesSchema)",
req: &GroupReportGenerateRequest{Name: ReportGroupQACheckIssues,
Schema: &GroupQACheckIssuesSchema{ProjectIDs: []int{1, 2}, Format: ReportFormatXLSX}},
valid: true,
},
{
name: "valid request (GroupTranslationActivitySchema)",
req: &GroupReportGenerateRequest{Name: ReportGroupTranslationActivity,
Schema: &GroupTranslationActivitySchema{ProjectIDs: []int{1}, Unit: ReportUnitWords}},
valid: true,
},
}

for _, tt := range tests {
Expand Down
Loading