diff --git a/haikudepotserver-core/src/main/java/org/haiku/haikudepotserver/pkg/job/PkgDumpExportJobRunner.java b/haikudepotserver-core/src/main/java/org/haiku/haikudepotserver/pkg/job/PkgDumpExportJobRunner.java index 34c906ad..21015577 100644 --- a/haikudepotserver-core/src/main/java/org/haiku/haikudepotserver/pkg/job/PkgDumpExportJobRunner.java +++ b/haikudepotserver-core/src/main/java/org/haiku/haikudepotserver/pkg/job/PkgDumpExportJobRunner.java @@ -42,10 +42,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.UncheckedIOException; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import java.util.zip.GZIPOutputStream; @@ -219,6 +216,7 @@ private DumpExportPkg createDumpPkg( Preconditions.checkArgument(null != pkgVersionsUnderCommonPkg && !pkgVersionsUnderCommonPkg.isEmpty()); Pkg pkg = pkgVersionsUnderCommonPkg.getFirst().getPkg(); // any will do to get the pkg. + PkgUserRatingAggregate userRatingAggregate = pkg.getPkgUserRatingAggregate(repositorySource.getRepository()).orElse(null); DumpExportPkg dumpExportPkg = new DumpExportPkg(); dumpExportPkg.setCreateTimestamp(pkg.getCreateTimestamp().getTime()); @@ -227,10 +225,12 @@ private DumpExportPkg createDumpPkg( dumpExportPkg.setHasChangelog(pkg.getPkgSupplement().getPkgChangelog().isPresent()); dumpExportPkg.setProminenceOrdering(pkg.tryGetPkgProminence(repositorySource.getRepository()) .map((p) -> p.getProminence().getOrdering()).map(Number::longValue).orElse(null)); - dumpExportPkg.setDerivedRating( - pkg.getPkgUserRatingAggregate(repositorySource.getRepository()) - .map((v) -> v.getDerivedRating().doubleValue()).orElse(null)); - + dumpExportPkg.setDerivedRating(Optional.ofNullable(userRatingAggregate) + .map((v) -> v.getDerivedRating().doubleValue()) + .orElse(null)); + dumpExportPkg.setDerivedRatingSampleSize(Optional.ofNullable(userRatingAggregate) + .map((v) -> v.getDerivedRatingSampleSize().longValue()) + .orElse(0L)); dumpExportPkg.setPkgCategories( pkg.getPkgSupplement().getPkgPkgCategories().stream().map((ppc) -> { DumpExportPkgCategory dumpExportPkgCategory = new DumpExportPkgCategory(); diff --git a/haikudepotserver-core/src/main/resources/schema/dumpexportpkg.json b/haikudepotserver-core/src/main/resources/schema/dumpexportpkg.json index 7dc224df..156df125 100644 --- a/haikudepotserver-core/src/main/resources/schema/dumpexportpkg.json +++ b/haikudepotserver-core/src/main/resources/schema/dumpexportpkg.json @@ -20,6 +20,10 @@ "derivedRating": { "type": "number" }, + "derivedRatingSampleSize": { + "description": "This is the number of user ratings that were used to create the derived rating. It may be zero if there are no user ratings.", + "type": "integer" + }, "hasChangelog": { "type": "boolean" },