diff options
Diffstat (limited to 'server/models/utils.ts')
-rw-r--r-- | server/models/utils.ts | 12 |
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 | ||
121 | function 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 | ||
123 | export { | 132 | export { |
@@ -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 | // --------------------------------------------------------------------------- |