1package interactors 2 3import ( 4 cst "repodiff/constants" 5 ent "repodiff/entities" 6) 7 8// AppProcessingParameters defines all possible inputs that are necessary 9// prior to applying any application business logic. Any outputs should 10// be derived from purely deterministic means; As such, the interactors 11// package should be 100% testable and free of any error return types 12type AppProcessingParameters struct { 13 DiffRows []ent.DiffRow 14 CommitRows []ent.CommitRow 15 Manifests *ent.ManifestFileGroup 16} 17 18func ApplyApplicationMutations(p AppProcessingParameters) ([]ent.AnalyzedDiffRow, []ent.AnalyzedCommitRow) { 19 projectNameToType := ProjectNamesToType(p.Manifests) 20 return diffRowsToAnalyzed(p.DiffRows, projectNameToType), 21 commitRowsToAnalyzed(p.CommitRows, projectNameToType) 22} 23 24func commitRowsToAnalyzed(commitRows []ent.CommitRow, projectNameToType TypeMap) []ent.AnalyzedCommitRow { 25 analyzed := make([]ent.AnalyzedCommitRow, len(commitRows)) 26 for i, row := range commitRows { 27 analyzed[i] = ent.AnalyzedCommitRow{ 28 CommitRow: row, 29 Type: projectNameToType.getWithDefault( 30 row.DownstreamProject, 31 cst.Empty, 32 ), 33 } 34 } 35 return analyzed 36} 37 38func diffRowsToAnalyzed(diffRows []ent.DiffRow, projectNameToType TypeMap) []ent.AnalyzedDiffRow { 39 analyzed := make([]ent.AnalyzedDiffRow, len(diffRows)) 40 for i, row := range diffRows { 41 analyzed[i] = ent.AnalyzedDiffRow{ 42 DiffRow: row, 43 Type: projectNameToType.getWithDefault( 44 row.DownstreamProject, 45 cst.Empty, 46 ), 47 } 48 } 49 return analyzed 50} 51