-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
742 lines (552 loc) · 29.2 KB
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
import mysql.connector
class Model:
def __init__(self,host,user,password,database):
self.__host =host
self.__user =user
self.__password =password
self.__database =database
self.__conn = False
def initConn(self):
try:
dbconn = mysql.connector.connect(
host = self.__host,
user = self.__user,
password = self.__password,
database = self.__database
)
self.__conn = dbconn
return True
except:
return False
def hasConnection(self):
if(self.initConn()):
self.conn.close()
return True
return False
@property
def conn(self):
return self.__conn
@property
def cur(self):
return self.conn.cursor(prepared=True)
def querySelect(self,sql,*args):
"""
This will only fetchone
"""
if(self.initConn()):
try:
cur = self.cur
cur.execute(sql,args)
result = cur.fetchone()
if result:
result =dict(zip(cur.column_names, result))
self.conn.close()
return result
except Exception as e:
return {"error":e}
return {"error": "There is no connection"}
def querySelectAll(self,sql,*args):
"""
This will do fetch all
"""
error = {"error":"There is no connection"}
temp = []
temp.append(error)
error = tuple(temp)
if(self.initConn()):
try:
cur = self.cur
cur.execute(sql,args)
result = cur.fetchall()
if result:
temp = []
for x in result:
x = dict(zip(cur.column_names, x))
temp.append(x)
result = tuple(temp)
self.conn.close()
return result
except Exception as e:
temp = [{"error":str(e)}]
temp.append(error)
return tuple(temp)
return error
def queryInsert(self,sql,*args):
if(self.initConn()):
try:
cur = self.cur
cur.execute(sql,args)
self.conn.commit()
result = cur.rowcount
self.conn.close()
return str(result) + " record(s) inserted"
except Exception as e:
return str(e)
return "Error: There is no connection"
def queryInsertMany(self,sql,vals:list):
if(self.initConn()):
try:
cur = self.cur
cur.executemany(sql,vals)
self.conn.commit()
result = cur.rowcount
self.conn.close()
return str(result) + " record(s) inserted"
except Exception as e:
return str(e)
return "Error: There is no connection"
def queryUpdate(self,sql,*args):
if(self.initConn()):
try:
cur = self.cur
cur.execute(sql,args)
self.conn.commit()
result = cur.rowcount
self.conn.close()
return str(result) + " record(s) updated"
except Exception as e:
return str(e)
return "Error: There is no connection"
def queryDelete(self,sql,*args):
if(self.initConn()):
try:
cur = self.cur
cur.execute(sql,args)
self.conn.commit()
result = cur.rowcount
self.conn.close()
return str(result) + " record(s) deleted"
except Exception as e:
return str(e)
return "Error: There is no connection"
#================================================== Selects
def selectAccounts(self):
return self.querySelectAll("Select * from accounts")
def selectAccountViaEmail(self,email:str):
return self.querySelect("call sp_select_account_via_email(%s)",email)
def selectAccountActiveViaEmail(self,email:str):
return self.querySelect("call sp_select_account_active_via_email(%s)",email)
def selectAccountViaId(self,id:str):
return self.querySelect("call sp_select_account_via_id(%s)",id)
def selectAccountAccountViaId(self,id:str):
return self.querySelect("call sp_select_account_active_via_id(%s)",id)
def selectFeeds(self,id:str):
"""
As of now it only return the data for specific user
Admin Feeds is not yet included
"""
feeds = []
stmts = [
(str(self.countVideosUploadedByAcc(id).get("count")),"Uploaded Videos","info","video-camera","/videolist"),
(str(self.countBleepVideosUploadedByAcc(id).get("count")),"Bleeped Videos","olive","film","/bleepvideolist"),
(str(self.countProfanityWordsByAcc(id).get("count")),"Profanities Collected","maroon","comments-o","/profanities"),
(str(self.countUniqueProfanityWordsByAcc(id).get("count")),"Unique Profanities","purple","commenting-o","/uniqueprofanities")
]
for stmt in stmts:
feed = {
"count":stmt[0],
"title":stmt[1].title(),
"bgcolor":stmt[2],
"icon":stmt[3],
"link":stmt[4]
}
feeds.append(feed)
return feeds
def selectLatestBleepSound(self):
return self.querySelect("call sp_select_latest_bleep_sound()")
def selectLatestBleepSoundSearch(self,search):
return self.querySelect("call sp_select_latest_bleep_sound_search(%s)",search)
def selectLatestBleep(self,id:str):
return self.querySelect("call sp_select_latest_censored_videos_by_account(%s)",id)
def selectLatestBleepSearch(self,id:str,search):
return self.querySelect("call sp_select_latest_censored_videos_by_account_search(%s,%s)",id,search)
def selectLatestBleepAll(self):
return self.querySelect("call sp_select_latest_censored_videos_all()")
def selectLatestBleepAllSearch(self,search):
return self.querySelect("call sp_select_latest_censored_videos_all_search(%s)",search)
def selectLatestUploadedVideo(self,id:str):
return self.querySelect("call sp_select_latest_video_by_account(%s)",id)
def selectLatestUploadedVideoSearch(self,id:str,search):
return self.querySelect("call sp_select_latest_video_by_account_search(%s,%s)",id,search)
def selectLatestUploadedVideoAll(self):
return self.querySelect("call sp_select_latest_video_all()")
def selectLatestUploadedVideoAllSearch(self,search):
return self.querySelect("call sp_select_latest_video_all_search(%s)",search)
def selectLatestBleepDataBuilder(self,latestbleep:dict):
latestbleep_data = {}
if latestbleep:
latestbleep_data ={
"latestbleep":latestbleep,
"uniqueprofanities":self.selectUniqueProfanityWordsByVideo(latestbleep.get("pvideo_id")),
"uniqueprofanitycount":self.countUniqueProfanityWordsByBleepedVideo(latestbleep.get("pvideo_id")).get("count"),
"mostfrequentword":self.selectMostFrequentProfanityWordByVideo(latestbleep.get("pvideo_id")).get("word")
}
return latestbleep_data
def selectLatestBleepSummaryData(self,id:str):
latestbleep = self.selectLatestBleep(id)
return self.selectLatestBleepDataBuilder(latestbleep)
def selectLatestBleepSummaryDataSearch(self,id:str,search):
latestbleep = self.selectLatestBleepSearch(id,search)
return self.selectLatestBleepDataBuilder(latestbleep)
def selectLatestBleepSummaryDataAll(self):
latestbleep = self.selectLatestBleepAll()
return self.selectLatestBleepDataBuilder(latestbleep)
def selectLatestBleepSummaryDataAllSearch(self,search):
latestbleep = self.selectLatestBleepAllSearch(search)
return self.selectLatestBleepDataBuilder(latestbleep)
def selectBleepInfoDataBuilder(self,bleepinfo:dict):
#bleepinfo should be a query
bleepinfo_data = {}
if bleepinfo:
advance_ave_data = self.averageProfanityVideoConfAndPredict(bleepinfo.get("pvideo_id"))
if not advance_ave_data:
advance_ave_data = {}
bleepinfo_data ={
"bleepinfo":bleepinfo,
"uniqueprofanities":self.selectUniqueProfanityWordsByVideo(bleepinfo.get("pvideo_id")),
"uniqueprofanitiesall":self.selectUniqueProfanityWordsByVideoAll(bleepinfo.get("pvideo_id")),
"profanitiesall":self.selectProfanitiesOfVideoAll(bleepinfo.get("pvideo_id")),
"uniqueprofanitycount":self.countUniqueProfanityWordsByBleepedVideo(bleepinfo.get("pvideo_id")).get("count"),
"profanitycount":self.countProfanityWordsByBleepedVideo(bleepinfo.get("pvideo_id")).get("count"),
"mostfrequentword":self.selectMostFrequentProfanityWordByVideo(bleepinfo.get("pvideo_id")).get("word"),
"top10profanities":self.selectTop10ProfanitiesByVideo(bleepinfo.get("pvideo_id")),
"uploadedby":bleepinfo.get("uploadedby"),
"countperlang":self.selectCountPerLangOfBleepVideo(bleepinfo.get("pvideo_id")),
"ave_conf_percentage":advance_ave_data.get('ave_conf_percentage'),
"ave_predict_prob_percentage":advance_ave_data.get('ave_predict_prob_percentage')
}
return bleepinfo_data
def selectBleepedVideoFullInfoById(self,id:str,pvid:str):
bleepinfo = self.selectBleepedVideosByAccountAndPvid(id,pvid)
return self.selectBleepInfoDataBuilder(bleepinfo)
def selectBleepedVideoFullInfo(self,pvid:str):
bleepinfo = self.selectBleepedVideoByPvid(pvid)
return self.selectBleepInfoDataBuilder(bleepinfo)
def selectUniqueProfanityWordsByVideo(self,pvid:str):
return self.querySelectAll("call sp_select_unique_profanitywords_of_video(%s)",pvid)
def selectUniqueProfanityWordsByVideoAll(self,pvid:str):
return self.querySelectAll("call sp_select_unique_profanitywords_of_video_All(%s)",pvid)
def selectMostFrequentProfanityWordByVideo(self,pvid:str):
return self.querySelect("call sp_select_most_frequent_profanity_word_of_video(%s)",pvid)
def selectProfanitiesOfVideo(self,pvid:str):
return self.querySelectAll("call sp_select_profanitywords_of_video(%s)",pvid)
def selectProfanitiesOfVideoAll(self,pvid:str):
return self.querySelectAll("call sp_select_profanitywords_of_video_all(%s)",pvid)
def selectUniqueProfanityWordsByAccount(self,id:str):
return self.querySelectAll("call sp_select_unique_profanitywords_by_account(%s)",id)
def selectTop10ProfanitiesByVideo(self,pvid):
return self.querySelectAll("call sp_select_top_10_profanities_by_video(%s)",pvid)
def selectTop10ProfanitiesAll(self):
return self.querySelectAll("call sp_select_top_10_profanities_all()")
def selectCountPerLangAll(self):
return self.querySelectAll("call sp_select_lang_of_pword_groupby_lang_all()")
def selectCountPerLangOfBleepVideo(self,pvid):
return self.querySelectAll("call sp_select_lang_of_pword_groupby_lang_by_video(%s)",pvid)
def selectCountPerLangOfAccount(self,acc_id):
return self.querySelectAll("call sp_select_lang_of_pword_groupby_lang_by_account(%s)",acc_id)
def selectBleepedVideosByAccount(self,id:str):
return self.querySelectAll("call sp_select_censored_videos_by_account(%s)",id)
def selectBleepedVideosByAccountSearchLimitOffset(self,id:str,search,limit,offset):
return self.querySelectAll("call sp_select_censored_videos_by_account_search_limit_offset(%s,%s,%s,%s)",id,search,limit,offset)
def selectBleepedVideosByAccountAndPvid(self,id:str,pvid:str):
return self.querySelect("call sp_select_censored_videos_by_acc_pvid(%s,%s)",id,pvid)
def selectBleepedVideosAll(self):
return self.querySelectAll("call sp_select_censored_videos_all()")
def selectBleepedVideosAllSearchLimitOffset(self,search,limit,offset):
return self.querySelectAll("call sp_select_censored_videos_all_search_limit_offset(%s,%s,%s)",search,limit,offset)
def selectBleepedVideoByPvid(self,pvid):
return self.querySelect("call sp_select_censored_videos_by_pvid(%s)",pvid)
def selectVideosUploadedByAccount(self,id:str):
return self.querySelectAll("call sp_select_videos_uploadedby_account(%s)",id)
def selectVideosUploadedByAccountSearch(self,id:str,search):
return self.querySelectAll("call sp_select_videos_uploadedby_account_search(%s,%s)",id,search)
def selectVideosUploadedByAccountSearchLimitOffset(self,id:str,search,limit,offset):
return self.querySelectAll("call sp_select_videos_uploadedby_account_search_limit_offset(%s,%s,%s,%s)",id,search,limit,offset)
def selectVideoByAccountAndVidId(self,id:str,vidid:str):
return self.querySelect("call sp_select_videos_by_account_vid_id(%s,%s)",id,vidid)
def selectVideoByUniqueFilename(self,uniquefilename):
return self.querySelect("call sp_select_video_by_uniquefilename(%s)",uniquefilename)
def selectVideoByVidId(self,vid_id):
return self.querySelect("call sp_select_video_by_id(%s)",vid_id)
def selectVideosAll(self):
return self.querySelectAll("call sp_select_videos_all()")
def selectVideosAllSearchLimitOffset(self,search,limit,offset):
return self.querySelectAll("call sp_select_videos_all_search_limit_offset(%s,%s,%s)",search,limit,offset)
def selectBleepSounds(self):
return self.querySelectAll("call sp_select_bleep_sounds_all()")
def selectBleepSoundsSearchLimitOffset(self,search,limit,offset):
return self.querySelectAll("call sp_select_bleep_sounds_all_search_limit_offset(%s,%s,%s)",search,limit,offset)
def selectBleepSoundById(self, bleepsoundid):
return self.querySelect("call sp_select_bleep_sound_by_bleepid(%s)",bleepsoundid)
def selectBleepVideoByFileName(self,pfilename):
return self.querySelect("call sp_select_pvideo_by_filename(%s)",pfilename)
def selectNavOfRole(self,role_id):
return self.querySelectAll("call sp_select_navs_of_role(%s)",role_id)
def selectAccRole(self,id):
return self.querySelect("call sp_select_account_role(%s)",id)
def selectFeedBuilder(self,stmts):
"""
STMTS List of Dictionaries with 5 items
count, title, bgcolor, icon, link
"""
feeds = []
for stmt in stmts:
feed = {
"count":stmt[0],
"title":stmt[1].title(),
"bgcolor":stmt[2],
"icon":stmt[3],
"link":stmt[4]
}
feeds.append(feed)
return feeds
def selectAdminFeeds(self):
stmts = [
(str(self.countVideos().get("count")),"Overall Uploaded Videos","info","video-camera","/videos"),
(str(self.countBleepVideos().get("count")),"Overall Bleeped Videos","olive","film","/bleepedvideos"),
(str(self.countProfanityWords().get("count")),"Overall Profanities Collected","maroon","comments-o","/profanities"),
(str(self.countUniqueProfanityWords().get("count")),"Overall Unique Profanities","purple","commenting-o","/uniqueprofanities")
]
return self.selectFeedBuilder(stmts)
def selectManageAccountFeeds(self):
stmts = [
(str(self.countAccounts().get('count')),"Total Users","info","users","/manageaccount"),
(str(self.countAccountsActive().get('count')),"Active","olive","user","/manageaccount"),
(str(self.countAccountsBlocked().get('count')),"Blocked","maroon","user-times","/manageblockaccount"),
# (str(0),"Reset Request","purple","envelope","/resetrequest")
]
return self.selectFeedBuilder(stmts)
def selectRoles(self):
return self.querySelectAll("call sp_select_roles()")
def selectNavByLocation(self,location):
return self.querySelect("call sp_select_nav_by_location(%s)",location)
def selectAccountCountsByRole(self):
feeds = []
icons = ["user-secret","user-circle-o","user","users"]
bgcolors =["info","olive","success","purple"]
stmts = []
for role in self.selectRoles():
stmts.append([str(self.countAccountByRoles(role.get("name")).get("count")), role.get("name")])
#add total
stmts.append([str(self.countAccounts().get("count")),"Total"])
i = 0
for stmt in stmts:
feed = {
"count":stmt[0],
"title":stmt[1].title(),
"bgcolor":bgcolors[i],
"icon":icons[i]
}
i+=1
feeds.append(feed)
return feeds
def selectLatestUsers(self):
return self.querySelectAll("call sp_select_latest_users()")
def selectLatestActiveUsers(self):
return self.querySelectAll("call sp_select_latest_active_users()")
def selectAccountRegTrend(self):
return self.querySelectAll("call sp_select_trend_account_reg()")
def selectUploadVideoTrend(self):
return self.querySelectAll("call sp_select_trend_upload_video()")
def selectBleepsoundTrend(self):
return self.querySelectAll("call sp_select_trend_bleep_sound()")
def selectBleepVideoTrend(self):
return self.querySelectAll("call sp_select_trend_bleep_video()")
def selectTrendFeed(self):
dates = []
registration = []
videouploads = []
bleepvideos = []
bleepsounds = []
for items in self.selectAccountRegTrend():
registration.append(items.get("count"))
dates.append(items.get("date"))
for items in self.selectUploadVideoTrend():
videouploads.append(items.get("count"))
for items in self.selectBleepVideoTrend():
bleepvideos.append(items.get("count"))
for items in self.selectBleepsoundTrend():
bleepsounds.append(items.get("count"))
trends = [
{"Registration ": registration},
{"Video Uploads ": videouploads},
{"Bleep Video ": bleepvideos},
{"Bleep Sound":bleepsounds}
]
feeds = {
"trends":trends,
"dates":dates
}
return feeds
def selectAccountsAll(self):
return self.querySelectAll("call sp_select_accounts_all()")
def selectAccountsActiveAll(self):
return self.querySelectAll("call sp_select_accounts_active_all()")
def selectAccountsAllLimitOffset(self,limit,offset):
return self.querySelectAll("call sp_select_accounts_all_limit_offset(%s,%s)",limit,offset)
def selectAccountsActiveAllLimitOffset(self,limit,offset):
return self.querySelectAll("call sp_select_accounts_active_all_limit_offset(%s,%s)",limit,offset)
def selectAccountAllSearchLimitOffset(self,search,limit,offset):
return self.querySelectAll("call sp_select_accounts_all_search_limit_offset(%s,%s,%s)",search,limit,offset)
def selectAccountActiveAllSearchLimitOffset(self,search,limit,offset):
return self.querySelectAll("call sp_select_accounts_active_all_search_limit_offset(%s,%s,%s)",search,limit,offset)
def selectAccountBlockAllSearchLimitOffset(self,search,limit,offset):
return self.querySelectAll("call sp_select_accounts_block_all_search_limit_offset(%s,%s,%s)",search,limit,offset)
def selectLangByLang(self,lang):
return self.querySelect("call sp_select_lang_by_lang(%s)",lang)
def selectLangById(self,lang_id):
return self.querySelect("call sp_language_by_id(%s)",lang_id)
def selectLangsAll(self):
return self.querySelectAll("call sp_select_languages()")
def selectSTTModelByLangId(self,lang_id):
return self.querySelectAll("call sp_select_stt_model_by_lang_id(%s)",lang_id)
def selectSTTModelByLang(self,lang):
return self.querySelectAll("call sp_select_stt_model_by_lang(%s)",lang)
def selectSTTModelById(self,stt_model_id):
return self.querySelect("call sp_select_stt_model_by_id(%s)",stt_model_id)
def selectAccountStatusDefaults(self):
return self.querySelectAll("call sp_select_account_status_defaults()")
def selectAccountStatusDefaultsViaStatus(self,status):
return self.querySelect("call sp_select_account_status_defaults_via_status(%s)",status)
#================================================== Counts
def countVideosUploadedByAcc(self,id:str):
return self.querySelect("call sp_count_videos_uploadedby_account(%s)",id)
def countVideosUploadedByAccSearch(self,id:str,search):
return self.querySelect("call sp_count_videos_uploadedby_account_search(%s,%s)",id,search)
def countBleepVideosUploadedByAcc(self,id:str):
return self.querySelect("call sp_count_censored_videos_by_accounts(%s)",id)
def countBleepVideosUploadedByAccSearch(self,id:str,search):
return self.querySelect("call sp_count_censored_videos_by_accounts_search(%s,%s)",id,search)
def countProfanityWordsByAcc(self,id:str):
return self.querySelect("call sp_count_profanitywords_collected_by_account(%s)",id)
def countUniqueProfanityWordsByAcc(self,id:str):
return self.querySelect("call sp_count_unique_profanitywords_collected_by_account(%s)",id)
def countProfanityWordsByBleepedVideo(self,pvid_id:str):
return self.querySelect("call sp_count_profanitywords_collected_by_video(%s)",pvid_id)
def countUniqueProfanityWordsByBleepedVideo(self,id:str):
return self.querySelect("call sp_count_unique_profanitywords_collected_by_video(%s)",id)
def countVideos(self):
return self.querySelect("call sp_count_videos()")
def countVideosSearch(self,search):
return self.querySelect("call sp_count_videos_search(%s)",search)
def countBleepVideos(self):
return self.querySelect("call sp_count_censored_videos()")
def countBleepVideosSearch(self,search):
return self.querySelect("call sp_count_censored_videos_search(%s)",search)
def countProfanityWords(self):
return self.querySelect("call sp_count_profanitywords_collected()")
def countUniqueProfanityWords(self):
return self.querySelect("call sp_count_unique_profanitywords_collected()")
def countAccountByRoles(self,role):
return self.querySelect("call sp_count_accounts_by_roles(%s)",role)
def countAccounts(self):
return self.querySelect("call sp_count_accounts()")
def countAccountsActive(self):
return self.querySelect("call sp_count_accounts_active()")
def countAccountsBlocked(self):
return self.querySelect("call sp_count_accounts_blocked()")
def countAccountsSearch(self,search):
return self.querySelect("call sp_count_accounts_search(%s)",search)
def countAccountsActiveSearch(self,search):
return self.querySelect("call sp_count_accounts_active_search(%s)",search)
def countAccountsBlockSearch(self,search):
return self.querySelect("call sp_count_accounts_block_search(%s)",search)
def countBleepSoundSearch(self,search):
return self.querySelect("call sp_count_bleep_sound_search(%s)",search)
#================================================== Average
def averageProfanityVideoConfAndPredict(self,pvid_id):
return self.querySelect("call sp_ave_censored_video_profanity_word_conf_predict(%s)",pvid_id)
#================================================== Inserts
def insertRole(self,rolename):
return self.queryInsert("call sp_add_roles(%s)",rolename)
def insertVideo(self,filename,uniquefilename,filelocation,savedirectory):
return self.queryInsert("call sp_add_video(%s, %s, %s, %s)",filename,uniquefilename,filelocation,savedirectory)
def insertUploadedBy(self,vidid,id):
return self.queryInsert("call sp_add_uploadedby(%s, %s)",vidid,id)
def insertBleepedVideo(self,bleepvideodict:dict):
"""
Dictionary
- vid_id
- bleepsound_id
- pfilename
- pfilelocation
- psavedirectory
- stt_model_id
"""
return self.queryInsert("call sp_add_profanityvideo(%s,%s, %s, %s, %s, %s)",
bleepvideodict.get('vid_id'),
bleepvideodict.get('bleepsound_id'),
bleepvideodict.get('pfilename'),
bleepvideodict.get('pfilelocation'),
bleepvideodict.get('psavedirectory'),
bleepvideodict.get('stt_model_id')
)
def insertRefilterVideo(self,refiltervideodict:dict):
"""
Dictionary
- vid_id
- bleepsound_id
- pfilename
- pfilelocation
- psavedirectory
- stt_model_id,
- refilter_level,
- lastbleepvideoid
"""
return self.queryInsert("call sp_add_refiltervideo(%s,%s, %s, %s, %s, %s,%s,%s)",
refiltervideodict.get('vid_id'),
refiltervideodict.get('bleepsound_id'),
refiltervideodict.get('pfilename'),
refiltervideodict.get('pfilelocation'),
refiltervideodict.get('psavedirectory'),
refiltervideodict.get('stt_model_id'),
refiltervideodict.get('refilter_level'),
refiltervideodict.get('lastbleepvideoid')
)
def insertProfanities(self,vals:list):
#word , start, end, lang_id, p_conf, p_predict,pvid_id
return self.queryInsertMany("call sp_add_profanityword(%s, %s,%s,%s,%s,%s,%s)",vals)
def insertUser(self,email:str,fname:str,lname:str,pwd):
return self.queryInsert("call sp_add_user(%s, %s, %s, %s)",email,fname,lname,pwd)
def insertAccount(self,email,fname,lname,pwd,role_id):
return self.queryInsert("call sp_add_account(%s,%s,%s,%s,%s)",email,fname,lname,pwd,role_id)
def insertBleepSound(self,filename,uniquefilename,filelocation,longversion):
return self.queryInsert("call sp_add_bleep_sound(%s,%s,%s,%s)",filename,uniquefilename,filelocation,longversion)
#================================================== Update
def updateAccFname(self,email,fname):
return self.queryUpdate("call sp_update_account_fname(%s,%s)",email,fname)
def updateAccLname(self,email,lname):
return self.queryUpdate("call sp_update_account_lname(%s,%s)",email,lname)
def updateAccPwd(self,email,pwd):
return self.queryUpdate("call sp_update_account_pwd(%s,%s)",email,pwd)
def updateAccEmail(self,oldemail,newemail):
return self.queryUpdate("call sp_update_account_email(%s,%s)",oldemail,newemail)
def updateAccPhoto(self,email,photo):
return self.queryUpdate("call sp_update_account_photo(%s,%s)",email,photo)
def updateAccFnameById(self,id,fname):
return self.queryUpdate("call sp_update_account_fname_by_id(%s,%s)",id,fname)
def updateAccLnameById(self,id,lname):
return self.queryUpdate("call sp_update_account_lname_by_id(%s,%s)",id,lname)
def updateAccPassword(self,id,pwd):
return self.queryUpdate("call sp_update_account_password(%s,%s)",id,pwd)
def updateAccRoleIdById(self,id,role_id):
return self.queryUpdate("call sp_update_account_role_id_by_id(%s,%s)",id,role_id)
def updateAccStatusById(self,id,status_id):
return self.queryUpdate("call sp_update_account_status_id_by_id(%s,%s)",id,status_id)
def updateBleepSoundFilenameById(self,bleepsound_id,filename):
return self.queryUpdate("call sp_update_bleep_sound_filename_by_id(%s,%s)",bleepsound_id,filename)
def updateBleepSoundById(self,bleepsound_id,filename,uniquefilename,filelocation,longversion):
return self.queryUpdate("call sp_update_bleep_sound_by_id(%s,%s,%s,%s,%s)",bleepsound_id,filename,uniquefilename,filelocation,longversion)
#================================================== Delete
def deleteAccById(self,id):
return self.queryDelete("call sp_delete_account_by_id(%s)",id)
def deleteUploadedById(self,id):
return self.queryDelete("call sp_delete_uploadedby_id(%s)",id)
def deleteVideoByVidId(self,vid_id):
return self.queryDelete("call sp_delete_video_by_vid_id(%s)",vid_id)
def deleteBleepVideoByVidId(self,pvid_id):
return self.queryDelete("call sp_delete_pvideo_by_pvid_id(%s)",pvid_id)
def deleteProfanityWordsByVidId(self,pvid_id):
return self.queryDelete("call sp_delete_pword_by_pvid_id(%s)",pvid_id)
def deleteBleepSoundById(self,bleepsound_id):
return self.queryDelete("call sp_delete_bleep_sound(%s)",bleepsound_id)