aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-23 09:50:57 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 16:26:21 +0200
commit3acc50844047a37698f0618fa235c138e386a053 (patch)
treee33243bf7fadbcf2df616fc41814245094fd881a /server/models/utils.ts
parent1735c825726edaa0af5035cb6cbb0cc0db502c6d (diff)
downloadPeerTube-3acc50844047a37698f0618fa235c138e386a053.tar.gz
PeerTube-3acc50844047a37698f0618fa235c138e386a053.tar.zst
PeerTube-3acc50844047a37698f0618fa235c138e386a053.zip
Upgrade sequelize
Diffstat (limited to 'server/models/utils.ts')
-rw-r--r--server/models/utils.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/server/models/utils.ts b/server/models/utils.ts
index 98170a00e..2b172f608 100644
--- a/server/models/utils.ts
+++ b/server/models/utils.ts
@@ -118,6 +118,15 @@ function buildWhereIdOrUUID (id: number | string) {
118 return validator.isInt('' + id) ? { id } : { uuid: id } 118 return validator.isInt('' + id) ? { id } : { uuid: id }
119} 119}
120 120
121function parseAggregateResult (result: any) {
122 if (!result) return 0
123
124 const total = parseInt(result + '', 10)
125 if (isNaN(total)) return 0
126
127 return total
128}
129
121// --------------------------------------------------------------------------- 130// ---------------------------------------------------------------------------
122 131
123export { 132export {
@@ -131,7 +140,8 @@ export {
131 buildServerIdsFollowedBy, 140 buildServerIdsFollowedBy,
132 buildTrigramSearchIndex, 141 buildTrigramSearchIndex,
133 buildWhereIdOrUUID, 142 buildWhereIdOrUUID,
134 isOutdated 143 isOutdated,
144 parseAggregateResult
135} 145}
136 146
137// --------------------------------------------------------------------------- 147// ---------------------------------------------------------------------------