@@ -71,8 +71,19 @@ func (thm *templateHeatmapRow) addParts(depth int, pathLeft []string, filePath s
7171 thm .builder [nextElement ].addParts (depth + 1 , pathLeft [1 :], filePath , instrumented , covered , timePeriod )
7272}
7373
74- func (thm * templateHeatmapRow ) prepareDataFor (pageColumns []pageColumnTarget ) {
75- thm .Items = maps .Values (thm .builder )
74+ func (thm * templateHeatmapRow ) prepareDataFor (pageColumns []pageColumnTarget , skipEmpty bool ) {
75+ for _ , item := range thm .builder {
76+ if ! skipEmpty {
77+ thm .Items = append (thm .Items , item )
78+ continue
79+ }
80+ for _ , hitCount := range item .covered {
81+ if hitCount > 0 {
82+ thm .Items = append (thm .Items , item )
83+ break
84+ }
85+ }
86+ }
7687 sort .Slice (thm .Items , func (i , j int ) bool {
7788 if thm .Items [i ].IsDir != thm .Items [j ].IsDir {
7889 return thm .Items [i ].IsDir
@@ -102,7 +113,7 @@ func (thm *templateHeatmapRow) prepareDataFor(pageColumns []pageColumnTarget) {
102113 thm .LastDayInstrumented = thm .instrumented [lastDate ]
103114 }
104115 for _ , item := range thm .builder {
105- item .prepareDataFor (pageColumns )
116+ item .prepareDataFor (pageColumns , skipEmpty )
106117 }
107118}
108119
@@ -131,7 +142,7 @@ type pageColumnTarget struct {
131142 Commit string
132143}
133144
134- func filesCoverageToTemplateData (fCov []* fileCoverageWithDetails ) * templateHeatmap {
145+ func filesCoverageToTemplateData (fCov []* fileCoverageWithDetails , hideEmpty bool ) * templateHeatmap {
135146 res := templateHeatmap {
136147 Root : & templateHeatmapRow {
137148 IsDir : true ,
@@ -164,7 +175,7 @@ func filesCoverageToTemplateData(fCov []*fileCoverageWithDetails) *templateHeatm
164175 res .Periods = append (res .Periods , fmt .Sprintf ("%s(%d)" , tp .DateTo .String (), tp .Days ))
165176 }
166177
167- res .Root .prepareDataFor (targetDateAndCommits )
178+ res .Root .prepareDataFor (targetDateAndCommits , hideEmpty )
168179 return & res
169180}
170181
@@ -403,7 +414,7 @@ func DoHeatMapStyleBodyJS(
403414 if err != nil {
404415 return "" , "" , "" , fmt .Errorf ("failed to filesCoverageWithDetails: %w" , err )
405416 }
406- templData := filesCoverageToTemplateData (covAndDates )
417+ templData := filesCoverageToTemplateData (covAndDates , onlyUnique )
407418 templData .Subsystems = sss
408419 templData .Managers = managers
409420 return stylesBodyJSTemplate (templData )
@@ -430,7 +441,7 @@ func DoSubsystemsHeatMapStyleBodyJS(
430441 ssCovAndDates = append (ssCovAndDates , & newRecord )
431442 }
432443 }
433- templData := filesCoverageToTemplateData (ssCovAndDates )
444+ templData := filesCoverageToTemplateData (ssCovAndDates , onlyUnique )
434445 templData .Managers = managers
435446 return stylesBodyJSTemplate (templData )
436447}
0 commit comments