]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/utils.ts
Relax videos list thumbnail api join
[github/Chocobozzz/PeerTube.git] / server / models / utils.ts
index 98170a00e14ec2c7275e8992b9874d3c2f3e1b09..2b172f6081e3eea7437a11010968af414ae76ab2 100644 (file)
@@ -118,6 +118,15 @@ function buildWhereIdOrUUID (id: number | string) {
   return validator.isInt('' + id) ? { id } : { uuid: id }
 }
 
+function parseAggregateResult (result: any) {
+  if (!result) return 0
+
+  const total = parseInt(result + '', 10)
+  if (isNaN(total)) return 0
+
+  return total
+}
+
 // ---------------------------------------------------------------------------
 
 export {
@@ -131,7 +140,8 @@ export {
   buildServerIdsFollowedBy,
   buildTrigramSearchIndex,
   buildWhereIdOrUUID,
-  isOutdated
+  isOutdated,
+  parseAggregateResult
 }
 
 // ---------------------------------------------------------------------------