Skip to content

Commit

Permalink
added flatten report functions
Browse files Browse the repository at this point in the history
Signed-off-by: quobix <[email protected]>
  • Loading branch information
daveshanley committed Feb 21, 2024
1 parent cf74572 commit aee63b5
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cmd/flatten_report.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2023-2024 Princess Beef Heavy Industries, LLC / Dave Shanley
// https://pb33f.io

package cmd

import (
whatChanged "github.com/pb33f/libopenapi/what-changed/model"
"github.com/pb33f/openapi-changes/model"
)

func FlattenReport(report *model.Report) *model.FlatReport {

flatReport := &model.FlatReport{}
flatReport.Summary = report.Summary
var changes []*whatChanged.Change
rpt := report.Commit.Changes
for _, change := range rpt.GetAllChanges() {
changes = append(changes, change)
}
flatReport.Changes = changes
return flatReport
}

func FlattenHistoricalReport(report *model.HistoricalReport) *model.FlatHistoricalReport {

flatReport := &model.FlatHistoricalReport{}
flatReport.GitRepoPath = report.GitRepoPath
flatReport.GitFilePath = report.GitFilePath
flatReport.DateGenerated = report.DateGenerated
flatReport.Filename = report.Filename
for _, r := range report.Reports {
flatReport.Reports = append(flatReport.Reports, FlattenReport(r))
}
return flatReport
}

0 comments on commit aee63b5

Please sign in to comment.