File tree Expand file tree Collapse file tree 3 files changed +584
-3
lines changed Expand file tree Collapse file tree 3 files changed +584
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
66and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
77
8+ ## [ 0.7.1] - 2025-10-28
9+ ### Fixed
10+ - Fix sorting order of results. Now sorting by ` Order ` field in ascending order, instead of ` PathId ` .
11+
812## [ 0.7.0] - 2025-10-24
913## Changed
1014- Update qdrant's docker compose file name
@@ -46,3 +50,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4650[ 0.5.0 ] : https://github.com/scanoss/folder-hashing-api/compare/v0.4.2...v0.5.0
4751[ 0.6.0 ] : https://github.com/scanoss/folder-hashing-api/compare/v0.5.0...v0.6.0
4852[ 0.7.0 ] : https://github.com/scanoss/folder-hashing-api/compare/v0.6.0...v0.7.0
53+ [ 0.7.1 ] : https://github.com/scanoss/folder-hashing-api/compare/v0.7.0...v0.7.1
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package service
1818
1919import (
2020 "context"
21+ "math"
2122 "sort"
2223
2324 "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
@@ -221,9 +222,23 @@ func (s *ScanServiceImpl) deduplicateComponents(results []*entities.ScanResult)
221222 }
222223 }
223224
224- sort .Slice (deduplicatedResults , func (i , j int ) bool {
225- return deduplicatedResults [i ].PathID < deduplicatedResults [j ].PathID
226- })
225+ sortByBestComponentOrder (deduplicatedResults )
227226
228227 return deduplicatedResults
229228}
229+
230+ // sortByBestComponentOrder sorts the results by the lowest order of the component groups (lower order is better).
231+ func sortByBestComponentOrder (results []* entities.ScanResult ) {
232+ sort .SliceStable (results , func (i , j int ) bool {
233+ minOrderI := int32 (math .MaxInt32 )
234+ for _ , group := range results [i ].ComponentGroups {
235+ minOrderI = min (minOrderI , group .Order )
236+ }
237+
238+ minOrderJ := int32 (math .MaxInt32 )
239+ for _ , group := range results [j ].ComponentGroups {
240+ minOrderJ = min (minOrderJ , group .Order )
241+ }
242+ return minOrderI < minOrderJ
243+ })
244+ }
You can’t perform that action at this time.
0 commit comments