1
- import { db } from "../databases/databases" ;
1
+ import { db , privateDB } from "../databases/databases" ;
2
2
import { getHashCache } from "../utils/getHashCache" ;
3
3
import { isUserVIP } from "../utils/isUserVIP" ;
4
4
import { Request , Response } from "express" ;
@@ -144,6 +144,16 @@ async function getThumbnailSubmissionCount(userID: HashedUserID): Promise<number
144
144
}
145
145
}
146
146
147
+ async function getCasualSubmissionCount ( userID : HashedUserID ) : Promise < number > {
148
+ try {
149
+ const row = await privateDB . prepare ( "get" , `SELECT COUNT(DISTINCT "videoID") as "casualSubmissionCount" FROM "casualVotes" WHERE "userID" = ?` , [ userID ] , { useReplica : true } ) ;
150
+ return row ?. casualSubmissionCount ?? 0 ;
151
+ } catch ( err ) /* istanbul ignore next */ {
152
+ return null ;
153
+ }
154
+ }
155
+
156
+
147
157
type cases = Record < string , any >
148
158
149
159
const executeIfFunction = ( f : any ) =>
@@ -173,6 +183,7 @@ const dbGetValue = (userID: HashedUserID, property: string): Promise<string|Segm
173
183
freeChaptersAccess : ( ) => true ,
174
184
titleSubmissionCount : ( ) => getTitleSubmissionCount ( userID ) ,
175
185
thumbnailSubmissionCount : ( ) => getThumbnailSubmissionCount ( userID ) ,
186
+ casualSubmissionCount : ( ) => getCasualSubmissionCount ( userID ) ,
176
187
} ) ( "" ) ( property ) ;
177
188
} ;
178
189
@@ -183,7 +194,7 @@ async function getUserInfo(req: Request, res: Response): Promise<Response> {
183
194
"viewCount" , "ignoredViewCount" , "warnings" , "warningReason" , "reputation" ,
184
195
"vip" , "lastSegmentID" ] ;
185
196
const allProperties : string [ ] = [ ...defaultProperties , "banned" , "permissions" , "freeChaptersAccess" ,
186
- "ignoredSegmentCount" , "titleSubmissionCount" , "thumbnailSubmissionCount" , "deArrowWarningReason" ] ;
197
+ "ignoredSegmentCount" , "titleSubmissionCount" , "thumbnailSubmissionCount" , "casualSubmissionCount" , " deArrowWarningReason"] ;
187
198
let paramValues : string [ ] = req . query . values
188
199
? JSON . parse ( req . query . values as string )
189
200
: req . query . value
0 commit comments