myanimebot-init.sql 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. -- --------------------------------------------------------
  2. -- Server version: 10.5.12-MariaDB-log - FreeBSD Ports
  3. -- Server OS: FreeBSD12.2
  4. -- HeidiSQL Version: 11.3.0.6295
  5. -- --------------------------------------------------------
  6. /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  7. /*!40101 SET NAMES utf8 */;
  8. /*!50503 SET NAMES utf8mb4 */;
  9. /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
  10. /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
  11. /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
  12. -- Dumping structure for view myanimebot.check_DuplicateFeeds
  13. -- Creating temporary table to overcome VIEW dependency errors
  14. CREATE TABLE `check_DuplicateFeeds` (
  15. `published` DATETIME NOT NULL,
  16. `last seen` DATETIME NULL,
  17. `service` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci',
  18. `title` MEDIUMTEXT NULL COLLATE 'utf8mb4_general_ci',
  19. `user` TINYTEXT NULL COLLATE 'utf8mb4_general_ci',
  20. `total` BIGINT(21) NOT NULL
  21. ) ENGINE=MyISAM;
  22. -- Dumping structure for view myanimebot.check_DuplicateMedia
  23. -- Creating temporary table to overcome VIEW dependency errors
  24. CREATE TABLE `check_DuplicateMedia` (
  25. `guid` MEDIUMTEXT NOT NULL COLLATE 'utf8mb4_general_ci',
  26. `service` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci',
  27. `title` MEDIUMTEXT NULL COLLATE 'utf8mb4_general_ci',
  28. `total` BIGINT(21) NOT NULL
  29. ) ENGINE=MyISAM;
  30. -- Dumping structure for view myanimebot.check_EmptyThumbnail
  31. -- Creating temporary table to overcome VIEW dependency errors
  32. CREATE TABLE `check_EmptyThumbnail` (
  33. `id` INT(11) UNSIGNED NOT NULL,
  34. `service` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci',
  35. `guid` MEDIUMTEXT NOT NULL COLLATE 'utf8mb4_general_ci',
  36. `title` MEDIUMTEXT NULL COLLATE 'utf8mb4_general_ci',
  37. `thumbnail` MEDIUMTEXT NULL COLLATE 'utf8mb4_general_ci'
  38. ) ENGINE=MyISAM;
  39. -- Dumping structure for view myanimebot.check_EventExecution
  40. -- Creating temporary table to overcome VIEW dependency errors
  41. CREATE TABLE `check_EventExecution` (
  42. `table` VARCHAR(64) NOT NULL COLLATE 'utf8_general_ci',
  43. `refreshed` DATETIME NULL
  44. ) ENGINE=MyISAM;
  45. -- Dumping structure for view myanimebot.check_Index
  46. -- Creating temporary table to overcome VIEW dependency errors
  47. CREATE TABLE `check_Index` (
  48. `table` VARCHAR(192) NOT NULL COLLATE 'utf8_general_ci',
  49. `index` VARCHAR(192) NOT NULL COLLATE 'utf8_general_ci',
  50. `read` BIGINT(21) NOT NULL
  51. ) ENGINE=MyISAM;
  52. -- Dumping structure for view myanimebot.check_OrphanMedias
  53. -- Creating temporary table to overcome VIEW dependency errors
  54. CREATE TABLE `check_OrphanMedias` (
  55. `id` INT(11) UNSIGNED NOT NULL,
  56. `service` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci',
  57. `media` MEDIUMTEXT NULL COLLATE 'utf8mb4_general_ci'
  58. ) ENGINE=MyISAM;
  59. -- Dumping structure for view myanimebot.check_TablesDiskUsage
  60. -- Creating temporary table to overcome VIEW dependency errors
  61. CREATE TABLE `check_TablesDiskUsage` (
  62. `table` VARCHAR(64) NOT NULL COLLATE 'utf8_general_ci',
  63. `dataMB` DECIMAL(24,2) NULL,
  64. `indexMB` DECIMAL(24,2) NULL,
  65. `totalMB` DECIMAL(25,2) NULL,
  66. `total` BIGINT(22) UNSIGNED NULL
  67. ) ENGINE=MyISAM;
  68. -- Dumping structure for event myanimebot.event_generate_DailyAveragePerUser
  69. DELIMITER //
  70. CREATE EVENT `event_generate_DailyAveragePerUser` ON SCHEDULE EVERY 1 DAY STARTS '2020-01-05 01:30:00' ON COMPLETION PRESERVE ENABLE DO BEGIN
  71. CALL spe_generate_DailyAveragePerUser;
  72. END//
  73. DELIMITER ;
  74. -- Dumping structure for event myanimebot.event_generate_TopAnimes
  75. DELIMITER //
  76. CREATE EVENT `event_generate_TopAnimes` ON SCHEDULE EVERY 1 DAY STARTS '2019-12-08 05:00:00' ON COMPLETION PRESERVE ENABLE DO BEGIN
  77. CALL spe_generate_TopAnimes;
  78. END//
  79. DELIMITER ;
  80. -- Dumping structure for event myanimebot.event_generate_TopUniqueAnimePerUsers
  81. DELIMITER //
  82. CREATE EVENT `event_generate_TopUniqueAnimePerUsers` ON SCHEDULE EVERY 1 DAY STARTS '2019-11-05 05:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Daily job' DO BEGIN
  83. CALL spe_generate_TopUniqueAnimePerUsers;
  84. END//
  85. DELIMITER ;
  86. -- Dumping structure for event myanimebot.event_generate_TotalDifferentAnimesPerUser
  87. DELIMITER //
  88. CREATE EVENT `event_generate_TotalDifferentAnimesPerUser` ON SCHEDULE EVERY 1 HOUR STARTS '2019-11-05 03:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Daily job' DO BEGIN
  89. CALL spe_generate_TotalDifferentAnimesPerUser;
  90. END//
  91. DELIMITER ;
  92. -- Dumping structure for event myanimebot.event_history
  93. DELIMITER //
  94. CREATE EVENT `event_history` ON SCHEDULE EVERY 10 MINUTE STARTS '2019-11-15 00:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Update the history table every 10 minutes' DO BEGIN
  95. # Initialization of my time variable
  96. SET @date = NOW();
  97. # We get the values that we want to store
  98. SELECT @totalFeeds := total FROM v_TotalFeeds;
  99. SELECT @totalUniqueFeeds := COUNT(0) FROM job_TopUniqueAnimePerUsers;
  100. SELECT @totalMedia := total FROM v_TotalAnimes;
  101. SELECT @totalUsers := COUNT(0) FROM t_users;
  102. SELECT @totalServers := COUNT(0) FROM t_servers;
  103. SELECT @totalDuplicateFeeds := COUNT(0) FROM check_DuplicateFeeds;
  104. SELECT @totalDuplicateMedia := COUNT(0) FROM check_DuplicateMedia;
  105. SELECT @totalEmptyThumbnail := COUNT(0) FROM check_EmptyThumbnail;
  106. SELECT @totalInactiveUsers := COUNT(0) FROM v_ActiveUsers WHERE active = '0';
  107. SELECT @spaceFeedsTable := total FROM check_TablesDiskUsage WHERE check_TablesDiskUsage.table = "t_feeds";
  108. SELECT @spaceAnimesTable := total FROM check_TablesDiskUsage WHERE check_TablesDiskUsage.table = "t_animes";
  109. SELECT @spaceUsersTable := total FROM check_TablesDiskUsage WHERE check_TablesDiskUsage.table = "t_users";
  110. SELECT @spaceServersTable := total FROM check_TablesDiskUsage WHERE check_TablesDiskUsage.table = "t_servers";
  111. SELECT @dailyAveragePerUser := ROUND(AVG(average), 3) FROM job_DailyAveragePerUser;
  112. SELECT @totalOrphanMedias := COUNT(0) FROM check_OrphanMedias;
  113. SELECT @nbMediaManga := total FROM v_CountMediaType WHERE v_CountMediaType.media = "manga";
  114. SELECT @nbMediaAnime := total FROM v_CountMediaType WHERE v_CountMediaType.media = "anime";
  115. SELECT @nbLog := -1;
  116. SELECT @nbErrorLog := -1;
  117. # We insert tour values
  118. INSERT INTO t_history (date, nbFeeds, nbUniqueFeeds, nbMedia, nbUsers, nbServers, nbDuplicateFeeds, nbDuplicateMedia, nbEmptyThumbnail, nbInactiveUsers, spaceFeedsTable, spaceAnimesTable, spaceUsersTable, spaceServersTable, dailyAveragePerUser, orphanMedias, nbMediaManga, nbMediaAnime, nbLog, nbErrorLog)
  119. VALUES (@date, @totalFeeds, @totalUniqueFeeds, @totalMedia, @totalUsers, @totalServers, @totalDuplicateFeeds, @totalDuplicateMedia, @totalEmptyThumbnail, @totalInactiveUsers, @spaceFeedsTable, @spaceAnimesTable, @spaceServersTable, @spaceServersTable, @dailyAveragePerUser, @totalOrphanMedias, @nbMediaManga, @nbMediaAnime, @nbLog, @nbErrorLog);
  120. END//
  121. DELIMITER ;
  122. -- Dumping structure for event myanimebot.event_maintenance
  123. DELIMITER //
  124. CREATE EVENT `event_maintenance` ON SCHEDULE EVERY 1 DAY STARTS '2019-11-17 06:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Executed at 6am, analyze the SQL tables' DO BEGIN
  125. # Using the stored procedure.
  126. CALL myanimebot.sp_Maintenance();
  127. END//
  128. DELIMITER ;
  129. -- Dumping structure for table myanimebot.job_DailyAveragePerUser
  130. CREATE TABLE IF NOT EXISTS `job_DailyAveragePerUser` (
  131. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  132. `user` tinytext DEFAULT NULL,
  133. `average` decimal(24,4) DEFAULT NULL,
  134. PRIMARY KEY (`id`),
  135. KEY `idx_user` (`user`(255))
  136. ) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COMMENT='Autogenerated - Average daily medias per user';
  137. -- Data exporting was unselected.
  138. -- Dumping structure for table myanimebot.job_TopAnimes
  139. CREATE TABLE IF NOT EXISTS `job_TopAnimes` (
  140. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  141. `anime` mediumtext DEFAULT NULL,
  142. `nbUser` bigint(21) NOT NULL DEFAULT 0,
  143. `total` bigint(21) NOT NULL DEFAULT 0,
  144. PRIMARY KEY (`id`),
  145. KEY `idx_anime` (`anime`(768))
  146. ) ENGINE=InnoDB AUTO_INCREMENT=5640 DEFAULT CHARSET=utf8mb4 COMMENT='Autogenerated - Top listed animes and number of users';
  147. -- Data exporting was unselected.
  148. -- Dumping structure for table myanimebot.job_TopUniqueAnimePerUsers
  149. CREATE TABLE IF NOT EXISTS `job_TopUniqueAnimePerUsers` (
  150. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  151. `user` tinytext DEFAULT NULL,
  152. `title` mediumtext DEFAULT NULL,
  153. `count` bigint(21) NOT NULL DEFAULT 0,
  154. PRIMARY KEY (`id`),
  155. KEY `idx_user` (`user`(255)),
  156. KEY `idx_title` (`title`(768))
  157. ) ENGINE=InnoDB AUTO_INCREMENT=9629 DEFAULT CHARSET=utf8mb4 COMMENT='Autogenerated - Unique Anime feeds per users';
  158. -- Data exporting was unselected.
  159. -- Dumping structure for table myanimebot.job_TotalDifferentAnimesPerUser
  160. CREATE TABLE IF NOT EXISTS `job_TotalDifferentAnimesPerUser` (
  161. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  162. `user` tinytext DEFAULT NULL,
  163. `total` bigint(21) NOT NULL DEFAULT 0,
  164. PRIMARY KEY (`id`),
  165. KEY `idx_user` (`user`(255))
  166. ) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COMMENT='Autogenerated - Total of different media per users';
  167. -- Data exporting was unselected.
  168. -- Dumping structure for procedure myanimebot.spe_generate_DailyAveragePerUser
  169. DELIMITER //
  170. CREATE PROCEDURE `spe_generate_DailyAveragePerUser`()
  171. SQL SECURITY INVOKER
  172. BEGIN
  173. # Create job_DailyAveragePerUser
  174. # We drop the curent table
  175. DROP TABLE IF EXISTS job_DailyAveragePerUser;
  176. # We recreate the table with the current result of the view
  177. CREATE TABLE job_DailyAveragePerUser IGNORE AS
  178. SELECT user, AVG(count) AS 'average'
  179. FROM (
  180. SELECT user, DATE(published) AS 'date', COUNT(*) AS 'count'
  181. FROM t_feeds
  182. WHERE DATE(published) != DATE(NOW())
  183. GROUP BY user, DATE
  184. ) AS temp_DailyAveragePerUser
  185. GROUP BY user
  186. ORDER BY average DESC
  187. ;
  188. # We apply the right configuration for the new table
  189. ALTER TABLE job_DailyAveragePerUser
  190. COMMENT="Autogenerated - Average daily medias per user"
  191. COLLATE='utf8mb4_general_ci'
  192. ENGINE=InnoDB
  193. ;
  194. # We create an ID column for the table
  195. ALTER TABLE job_DailyAveragePerUser
  196. ADD COLUMN `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
  197. ADD PRIMARY KEY (`id`)
  198. ;
  199. # We create indexes for the table
  200. CREATE INDEX idx_user ON job_DailyAveragePerUser(user);
  201. # And we analyze the created table
  202. ANALYZE TABLE job_DailyAveragePerUser;
  203. END//
  204. DELIMITER ;
  205. -- Dumping structure for procedure myanimebot.spe_generate_TopAnimes
  206. DELIMITER //
  207. CREATE PROCEDURE `spe_generate_TopAnimes`()
  208. SQL SECURITY INVOKER
  209. BEGIN
  210. # Create job_TopAnimes
  211. DROP TABLE IF EXISTS job_TopAnimes;
  212. # We recreate the table with the current result of the view
  213. CREATE TABLE job_TopAnimes AS SELECT * FROM v_TopAnimes;
  214. # We apply the right configuration for the new table
  215. ALTER TABLE job_TopAnimes
  216. COMMENT="Autogenerated - Top listed animes and number of users"
  217. COLLATE='utf8mb4_general_ci'
  218. ENGINE=InnoDB
  219. ;
  220. # We create an ID column for the table
  221. ALTER TABLE job_TopAnimes
  222. ADD COLUMN `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
  223. ADD PRIMARY KEY (`id`)
  224. ;
  225. # We create indexes for the table
  226. CREATE INDEX idx_anime ON job_TopAnimes(anime);
  227. # And we analyze the created table
  228. ANALYZE TABLE job_TopAnimes;
  229. END//
  230. DELIMITER ;
  231. -- Dumping structure for procedure myanimebot.spe_generate_TopUniqueAnimePerUsers
  232. DELIMITER //
  233. CREATE PROCEDURE `spe_generate_TopUniqueAnimePerUsers`()
  234. SQL SECURITY INVOKER
  235. BEGIN
  236. # Create job_TopUniqueAnimePerUsers
  237. # We drop the curent table
  238. DROP TABLE IF EXISTS job_TopUniqueAnimePerUsers;
  239. # We recreate the table with the current result of the view
  240. CREATE TABLE job_TopUniqueAnimePerUsers AS SELECT * FROM v_TopUniqueAnimePerUsers;
  241. # We apply the right configuration for the new table
  242. ALTER TABLE job_TopUniqueAnimePerUsers
  243. COMMENT="Autogenerated - Unique Anime feeds per users"
  244. COLLATE='utf8mb4_general_ci'
  245. ENGINE=InnoDB
  246. ;
  247. # We create an ID column for the table
  248. ALTER TABLE job_TopUniqueAnimePerUsers
  249. ADD COLUMN `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
  250. ADD PRIMARY KEY (`id`)
  251. ;
  252. # We create indexes for the table
  253. CREATE INDEX idx_user ON job_TopUniqueAnimePerUsers(user);
  254. CREATE INDEX idx_title ON job_TopUniqueAnimePerUsers(title);
  255. # And we analyze the created table
  256. ANALYZE TABLE job_TopUniqueAnimePerUsers;
  257. END//
  258. DELIMITER ;
  259. -- Dumping structure for procedure myanimebot.spe_generate_TotalDifferentAnimesPerUser
  260. DELIMITER //
  261. CREATE PROCEDURE `spe_generate_TotalDifferentAnimesPerUser`()
  262. SQL SECURITY INVOKER
  263. BEGIN
  264. # Create job_TotalDifferentAnimesPerUser
  265. # We drop the curent table
  266. DROP TABLE IF EXISTS job_TotalDifferentAnimesPerUser;
  267. # We recreate the table with the current result of the view
  268. CREATE TABLE job_TotalDifferentAnimesPerUser AS SELECT * FROM v_TotalDifferentAnimesPerUser;
  269. # We apply the right configuration for the new table
  270. ALTER TABLE job_TotalDifferentAnimesPerUser
  271. COMMENT="Autogenerated - Total of different media per users"
  272. COLLATE='utf8mb4_general_ci'
  273. ENGINE=InnoDB
  274. ;
  275. # We create an ID column for the table
  276. ALTER TABLE job_TotalDifferentAnimesPerUser
  277. ADD COLUMN `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
  278. ADD PRIMARY KEY (`id`)
  279. ;
  280. # We create indexes for the table
  281. CREATE INDEX idx_user ON job_TotalDifferentAnimesPerUser(user);
  282. # And we analyze the created table
  283. ANALYZE TABLE job_TotalDifferentAnimesPerUser;
  284. END//
  285. DELIMITER ;
  286. -- Dumping structure for procedure myanimebot.sp_AnimeCountPerKeyword
  287. DELIMITER //
  288. CREATE PROCEDURE `sp_AnimeCountPerKeyword`(
  289. IN `anime_var` TINYTEXT,
  290. IN `limit_var` INT
  291. )
  292. SQL SECURITY INVOKER
  293. COMMENT 'Procédure pour récupèrer les statistiques d''animés répondant à un mot clef'
  294. BEGIN
  295. -- Default value is infinite for limit_var
  296. IF limit_var = ''
  297. THEN SET limit_var = '-1';
  298. END IF;
  299. -- Procedure to get animes statistics linked to a keyword
  300. SELECT title AS 'title', COUNT(0) AS 'total'
  301. FROM t_feeds
  302. WHERE MATCH(title) AGAINST (anime_var)
  303. GROUP BY title
  304. ORDER BY COUNT(id) DESC
  305. LIMIT limit_var
  306. ;
  307. END//
  308. DELIMITER ;
  309. -- Dumping structure for procedure myanimebot.sp_AnimesPerUser
  310. DELIMITER //
  311. CREATE PROCEDURE `sp_AnimesPerUser`(
  312. IN `user_var` TINYTEXT,
  313. IN `limit_var` INT
  314. )
  315. SQL SECURITY INVOKER
  316. COMMENT 'Procédure pour récupèrer les statistiques d''animés sur un utilisateur'
  317. BEGIN
  318. -- Default value is infinite for limit_var
  319. IF limit_var = ''
  320. THEN SET limit_var = '-1';
  321. END IF;
  322. -- Procedure to get the statistics of user's animes
  323. SELECT
  324. title AS "title",
  325. COUNT(title) AS "total"
  326. FROM t_feeds
  327. WHERE user = user_var
  328. GROUP BY title
  329. ORDER BY COUNT(title) DESC
  330. LIMIT limit_var
  331. ;
  332. END//
  333. DELIMITER ;
  334. -- Dumping structure for procedure myanimebot.sp_InitBoot
  335. DELIMITER //
  336. CREATE PROCEDURE `sp_InitBoot`()
  337. SQL SECURITY INVOKER
  338. BEGIN
  339. # Generate all event tables
  340. CALL spe_generate_DailyAveragePerUser;
  341. CALL spe_generate_TopAnimes;
  342. CALL spe_generate_TopUniqueAnimePerUsers;
  343. CALL spe_generate_TotalDifferentAnimesPerUser;
  344. END//
  345. DELIMITER ;
  346. -- Dumping structure for procedure myanimebot.sp_Maintenance
  347. DELIMITER //
  348. CREATE PROCEDURE `sp_Maintenance`()
  349. BEGIN
  350. # Analyzing database's tables.
  351. ANALYZE TABLE t_animes, t_feeds, t_history, t_servers, t_sys, t_users;
  352. END//
  353. DELIMITER ;
  354. -- Dumping structure for procedure myanimebot.sp_RenameUser
  355. DELIMITER //
  356. CREATE PROCEDURE `sp_RenameUser`(
  357. IN `old_name_var` TINYTEXT,
  358. IN `new_name_var` TINYTEXT
  359. )
  360. MODIFIES SQL DATA
  361. SQL SECURITY INVOKER
  362. COMMENT 'Rename a user in the database.'
  363. BEGIN
  364. -- Rename a user in the database.
  365. -- For the table t_users
  366. UPDATE t_users
  367. SET t_users.mal_user = new_name_var
  368. WHERE t_users.mal_user = old_name_var;
  369. -- For the table t_animes
  370. UPDATE t_animes
  371. SET t_animes.discoverer = new_name_var
  372. WHERE t_animes.discoverer = old_name_var;
  373. -- For the table t_feeds
  374. UPDATE t_feeds
  375. SET t_feeds.user = new_name_var
  376. WHERE t_feeds.user = old_name_var;
  377. END//
  378. DELIMITER ;
  379. -- Dumping structure for procedure myanimebot.sp_TotalForKeyword
  380. DELIMITER //
  381. CREATE PROCEDURE `sp_TotalForKeyword`(
  382. IN `anime_var` TINYTEXT
  383. )
  384. SQL SECURITY INVOKER
  385. COMMENT 'Total des animés répondants à un mot clef'
  386. BEGIN
  387. -- Total of animés that contains a specific keyword
  388. SELECT COUNT(0) AS 'total'
  389. FROM t_feeds
  390. WHERE MATCH(title) AGAINST (anime_var)
  391. ;
  392. END//
  393. DELIMITER ;
  394. -- Dumping structure for procedure myanimebot.sp_UsersPerKeyword
  395. DELIMITER //
  396. CREATE PROCEDURE `sp_UsersPerKeyword`(
  397. IN `anime_var` TINYTEXT,
  398. IN `limit_var` INT
  399. )
  400. READS SQL DATA
  401. SQL SECURITY INVOKER
  402. COMMENT 'Statistiques des utilisateurs par rapport à un mot clef'
  403. BEGIN
  404. -- Default value is infinite for limit_var
  405. IF limit_var = ''
  406. THEN SET limit_var = '-1';
  407. END IF;
  408. -- Statistics of users according to a specific keyword
  409. SELECT user AS 'user', COUNT(title) AS 'total'
  410. FROM t_feeds
  411. WHERE MATCH(title) AGAINST(anime_var)
  412. GROUP BY user
  413. ORDER BY COUNT(title) DESC
  414. LIMIT limit_var
  415. ;
  416. END//
  417. DELIMITER ;
  418. -- Dumping structure for table myanimebot.t_animes
  419. CREATE TABLE IF NOT EXISTS `t_animes` (
  420. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  421. `guid` mediumtext NOT NULL,
  422. `service` tinytext NOT NULL DEFAULT 'mal',
  423. `title` mediumtext DEFAULT NULL,
  424. `thumbnail` mediumtext DEFAULT NULL,
  425. `found` datetime NOT NULL DEFAULT current_timestamp(),
  426. `discoverer` tinytext DEFAULT 'Anonymous',
  427. `media` tinytext DEFAULT 'unknown',
  428. PRIMARY KEY (`id`),
  429. UNIQUE KEY `idx_guid` (`guid`(768)) USING BTREE,
  430. KEY `idx_title` (`title`(768)),
  431. KEY `idx_discoverer` (`discoverer`(255)),
  432. KEY `idx_media` (`media`(255)),
  433. KEY `idx_service` (`service`(255)),
  434. FULLTEXT KEY `idx_title_str` (`title`)
  435. ) ENGINE=InnoDB AUTO_INCREMENT=5185 DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=224;
  436. -- Data exporting was unselected.
  437. -- Dumping structure for table myanimebot.t_feeds
  438. CREATE TABLE IF NOT EXISTS `t_feeds` (
  439. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  440. `published` datetime NOT NULL,
  441. `title` mediumtext DEFAULT NULL,
  442. `service` tinytext NOT NULL DEFAULT 'mal',
  443. `url` mediumtext NOT NULL,
  444. `user` tinytext DEFAULT NULL,
  445. `found` datetime NOT NULL DEFAULT current_timestamp(),
  446. `type` tinytext DEFAULT 'N/A',
  447. `obsolete` tinyint(3) unsigned NOT NULL DEFAULT 0,
  448. PRIMARY KEY (`id`),
  449. KEY `idx_user` (`user`(255)),
  450. KEY `idx_title` (`title`(768)),
  451. KEY `idx_published` (`published`),
  452. KEY `idx_type` (`type`(255)),
  453. KEY `idx_service` (`service`(255)),
  454. FULLTEXT KEY `idx_title_str` (`title`)
  455. ) ENGINE=InnoDB AUTO_INCREMENT=29821 DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=172;
  456. -- Data exporting was unselected.
  457. -- Dumping structure for table myanimebot.t_history
  458. CREATE TABLE IF NOT EXISTS `t_history` (
  459. `date` datetime NOT NULL,
  460. `nbFeeds` int(11) unsigned NOT NULL DEFAULT 0,
  461. `nbUniqueFeeds` int(11) unsigned NOT NULL DEFAULT 0,
  462. `nbMedia` int(11) unsigned NOT NULL DEFAULT 0,
  463. `nbUsers` int(11) unsigned NOT NULL DEFAULT 0,
  464. `nbServers` int(11) unsigned NOT NULL DEFAULT 0,
  465. `nbDuplicateFeeds` int(11) unsigned NOT NULL DEFAULT 0,
  466. `nbDuplicateMedia` int(11) unsigned NOT NULL DEFAULT 0,
  467. `nbEmptyThumbnail` int(11) unsigned NOT NULL DEFAULT 0,
  468. `nbInactiveUsers` int(11) unsigned NOT NULL DEFAULT 0,
  469. `spaceFeedsTable` int(11) unsigned NOT NULL DEFAULT 0,
  470. `spaceAnimesTable` int(11) unsigned NOT NULL DEFAULT 0,
  471. `spaceUsersTable` int(11) unsigned NOT NULL DEFAULT 0,
  472. `spaceServersTable` int(11) unsigned NOT NULL DEFAULT 0,
  473. `dailyAveragePerUser` float unsigned NOT NULL DEFAULT 0,
  474. `orphanMedias` int(11) unsigned NOT NULL DEFAULT 0,
  475. `nbMediaManga` int(11) unsigned NOT NULL DEFAULT 0,
  476. `nbMediaAnime` int(11) unsigned NOT NULL DEFAULT 0,
  477. `nbLog` int(11) NOT NULL DEFAULT 0,
  478. `nbErrorLog` int(11) NOT NULL DEFAULT 0,
  479. PRIMARY KEY (`date`) USING BTREE
  480. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='History of database';
  481. -- Data exporting was unselected.
  482. -- Dumping structure for table myanimebot.t_servers
  483. CREATE TABLE IF NOT EXISTS `t_servers` (
  484. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  485. `server` tinytext NOT NULL,
  486. `channel` tinytext DEFAULT NULL,
  487. `admin_group` tinytext DEFAULT NULL,
  488. PRIMARY KEY (`id`),
  489. UNIQUE KEY `idx_server` (`server`(255)) USING BTREE
  490. ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=5461;
  491. -- Data exporting was unselected.
  492. -- Dumping structure for table myanimebot.t_sys
  493. CREATE TABLE IF NOT EXISTS `t_sys` (
  494. `param` tinytext NOT NULL,
  495. `value` text DEFAULT NULL,
  496. PRIMARY KEY (`param`(100)) USING BTREE
  497. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  498. -- Data exporting was unselected.
  499. -- Dumping structure for table myanimebot.t_users
  500. CREATE TABLE IF NOT EXISTS `t_users` (
  501. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  502. `mal_user` tinytext NOT NULL,
  503. `service` tinytext NOT NULL DEFAULT 'mal',
  504. `servers` text DEFAULT NULL,
  505. `added` datetime NOT NULL DEFAULT current_timestamp(),
  506. PRIMARY KEY (`id`),
  507. KEY `idx_servers` (`servers`(768)),
  508. KEY `idx_service` (`service`(255)),
  509. KEY `idx_user` (`mal_user`(255)) USING BTREE,
  510. FULLTEXT KEY `idx_servers_str` (`servers`)
  511. ) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=1820 COMMENT='Table where are stored the users of this bot.';
  512. -- Data exporting was unselected.
  513. -- Dumping structure for view myanimebot.v_ActiveUsers
  514. -- Creating temporary table to overcome VIEW dependency errors
  515. CREATE TABLE `v_ActiveUsers` (
  516. `user` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci',
  517. `service` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci',
  518. `active` VARCHAR(1) NOT NULL COLLATE 'utf8mb4_general_ci'
  519. ) ENGINE=MyISAM;
  520. -- Dumping structure for view myanimebot.v_CountFeedsType
  521. -- Creating temporary table to overcome VIEW dependency errors
  522. CREATE TABLE `v_CountFeedsType` (
  523. `type` TINYTEXT NULL COLLATE 'utf8mb4_general_ci',
  524. `total` BIGINT(21) NOT NULL
  525. ) ENGINE=MyISAM;
  526. -- Dumping structure for view myanimebot.v_CountMediaType
  527. -- Creating temporary table to overcome VIEW dependency errors
  528. CREATE TABLE `v_CountMediaType` (
  529. `media` TINYTEXT NULL COLLATE 'utf8mb4_general_ci',
  530. `total` BIGINT(21) NOT NULL
  531. ) ENGINE=MyISAM;
  532. -- Dumping structure for view myanimebot.v_DailyHistory
  533. -- Creating temporary table to overcome VIEW dependency errors
  534. CREATE TABLE `v_DailyHistory` (
  535. `date` DATE NULL,
  536. `nbFeeds` INT(11) UNSIGNED NULL,
  537. `nbUniqueFeeds` INT(11) UNSIGNED NULL,
  538. `nbMedia` INT(11) UNSIGNED NULL,
  539. `nbUsers` INT(11) UNSIGNED NULL,
  540. `nbServers` INT(11) UNSIGNED NULL,
  541. `nbDuplacteFeeds` DECIMAL(12,0) NULL,
  542. `nbDuplicateMedia` DECIMAL(12,0) NULL,
  543. `nbEmptyThumbnail` DECIMAL(12,0) NULL,
  544. `nbInactiveUsers` DECIMAL(12,0) NULL,
  545. `spaceFeedsTable` DECIMAL(12,0) NULL,
  546. `spaceAnimesTable` DECIMAL(12,0) NULL,
  547. `SpaceUsersTable` DECIMAL(12,0) NULL,
  548. `SpaceServersTable` DECIMAL(12,0) NULL,
  549. `dailyAveragePerUser` DOUBLE(17,0) NULL,
  550. `orphanMedias` DECIMAL(12,0) NULL,
  551. `nbMediaManga` DECIMAL(12,0) NULL,
  552. `nbMediaAnime` DECIMAL(12,0) NULL,
  553. `nbLog` DECIMAL(11,0) NULL,
  554. `nbErrorLog` DECIMAL(11,0) NULL
  555. ) ENGINE=MyISAM;
  556. -- Dumping structure for view myanimebot.v_Top
  557. -- Creating temporary table to overcome VIEW dependency errors
  558. CREATE TABLE `v_Top` (
  559. `user` TINYTEXT NULL COLLATE 'utf8mb4_general_ci',
  560. `total` BIGINT(21) NOT NULL
  561. ) ENGINE=MyISAM;
  562. -- Dumping structure for view myanimebot.v_TopAnimes
  563. -- Creating temporary table to overcome VIEW dependency errors
  564. CREATE TABLE `v_TopAnimes` (
  565. `anime` MEDIUMTEXT NULL COLLATE 'utf8mb4_general_ci',
  566. `nbUser` BIGINT(21) NOT NULL,
  567. `total` BIGINT(21) NOT NULL
  568. ) ENGINE=MyISAM;
  569. -- Dumping structure for view myanimebot.v_TopUniqueAnimePerUsers
  570. -- Creating temporary table to overcome VIEW dependency errors
  571. CREATE TABLE `v_TopUniqueAnimePerUsers` (
  572. `user` TINYTEXT NULL COLLATE 'utf8mb4_general_ci',
  573. `title` MEDIUMTEXT NULL COLLATE 'utf8mb4_general_ci',
  574. `count` BIGINT(21) NOT NULL
  575. ) ENGINE=MyISAM;
  576. -- Dumping structure for view myanimebot.v_TotalAnimes
  577. -- Creating temporary table to overcome VIEW dependency errors
  578. CREATE TABLE `v_TotalAnimes` (
  579. `total` BIGINT(21) NOT NULL
  580. ) ENGINE=MyISAM;
  581. -- Dumping structure for view myanimebot.v_TotalDifferentAnimesPerUser
  582. -- Creating temporary table to overcome VIEW dependency errors
  583. CREATE TABLE `v_TotalDifferentAnimesPerUser` (
  584. `user` TINYTEXT NULL COLLATE 'utf8mb4_general_ci',
  585. `total` BIGINT(21) NOT NULL
  586. ) ENGINE=MyISAM;
  587. -- Dumping structure for view myanimebot.v_TotalFeeds
  588. -- Creating temporary table to overcome VIEW dependency errors
  589. CREATE TABLE `v_TotalFeeds` (
  590. `total` BIGINT(21) NOT NULL
  591. ) ENGINE=MyISAM;
  592. -- Dumping structure for view myanimebot.check_DuplicateFeeds
  593. -- Removing temporary table and create final VIEW structure
  594. DROP TABLE IF EXISTS `check_DuplicateFeeds`;
  595. CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `check_DuplicateFeeds` AS select `t_feeds`.`published` AS `published`,max(`t_feeds`.`found`) AS `last seen`,`t_feeds`.`service` AS `service`,`t_feeds`.`title` AS `title`,`t_feeds`.`user` AS `user`,count(0) AS `total` from `t_feeds` group by `t_feeds`.`published`,`t_feeds`.`title`,`t_feeds`.`user` having count(0) > 1;
  596. -- Dumping structure for view myanimebot.check_DuplicateMedia
  597. -- Removing temporary table and create final VIEW structure
  598. DROP TABLE IF EXISTS `check_DuplicateMedia`;
  599. CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `check_DuplicateMedia` AS select `t_animes`.`guid` AS `guid`,`t_animes`.`service` AS `service`,`t_animes`.`title` AS `title`,count(0) AS `total` from `t_animes` group by `t_animes`.`guid`,`t_animes`.`title` having count(0) > 1;
  600. -- Dumping structure for view myanimebot.check_EmptyThumbnail
  601. -- Removing temporary table and create final VIEW structure
  602. DROP TABLE IF EXISTS `check_EmptyThumbnail`;
  603. CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `check_EmptyThumbnail` AS select `t_animes`.`id` AS `id`,`t_animes`.`service` AS `service`,`t_animes`.`guid` AS `guid`,`t_animes`.`title` AS `title`,`t_animes`.`thumbnail` AS `thumbnail` from `t_animes` where `t_animes`.`thumbnail` = '' or `t_animes`.`thumbnail` is null;
  604. -- Dumping structure for view myanimebot.check_EventExecution
  605. -- Removing temporary table and create final VIEW structure
  606. DROP TABLE IF EXISTS `check_EventExecution`;
  607. CREATE ALGORITHM=MERGE SQL SECURITY DEFINER VIEW `check_EventExecution` AS select `information_schema`.`TABLES`.`TABLE_NAME` AS `table`,`information_schema`.`TABLES`.`CREATE_TIME` AS `refreshed` from `information_schema`.`TABLES` where `information_schema`.`TABLES`.`TABLE_NAME` like 'job\\_%' and `information_schema`.`TABLES`.`TABLE_SCHEMA` = 'myanimebot';
  608. -- Dumping structure for view myanimebot.check_Index
  609. -- Removing temporary table and create final VIEW structure
  610. DROP TABLE IF EXISTS `check_Index`;
  611. CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `check_Index` AS select `information_schema`.`INDEX_STATISTICS`.`TABLE_NAME` AS `table`,`information_schema`.`INDEX_STATISTICS`.`INDEX_NAME` AS `index`,`information_schema`.`INDEX_STATISTICS`.`ROWS_READ` AS `read` from `information_schema`.`INDEX_STATISTICS` where `information_schema`.`INDEX_STATISTICS`.`TABLE_SCHEMA` = 'myanimebot' and `information_schema`.`INDEX_STATISTICS`.`INDEX_NAME` <> 'PRIMARY' order by `information_schema`.`INDEX_STATISTICS`.`ROWS_READ` desc;
  612. -- Dumping structure for view myanimebot.check_OrphanMedias
  613. -- Removing temporary table and create final VIEW structure
  614. DROP TABLE IF EXISTS `check_OrphanMedias`;
  615. CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `check_OrphanMedias` AS select `t_animes`.`id` AS `id`,`t_animes`.`service` AS `service`,`t_animes`.`title` AS `media` from `t_animes` where !exists(select distinct `t_feeds`.`title` from `t_feeds` where `t_feeds`.`title` = `t_animes`.`title` limit 1);
  616. -- Dumping structure for view myanimebot.check_TablesDiskUsage
  617. -- Removing temporary table and create final VIEW structure
  618. DROP TABLE IF EXISTS `check_TablesDiskUsage`;
  619. CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `check_TablesDiskUsage` AS select `information_schema`.`TABLES`.`TABLE_NAME` AS `table`,round(`information_schema`.`TABLES`.`DATA_LENGTH` / 1024 / 1024,2) AS `dataMB`,round(`information_schema`.`TABLES`.`INDEX_LENGTH` / 1024 / 1024,2) AS `indexMB`,round((`information_schema`.`TABLES`.`DATA_LENGTH` + `information_schema`.`TABLES`.`INDEX_LENGTH`) / 1024 / 1024,2) AS `totalMB`,`information_schema`.`TABLES`.`DATA_LENGTH` + `information_schema`.`TABLES`.`INDEX_LENGTH` AS `total` from `INFORMATION_SCHEMA`.`TABLES` where `information_schema`.`TABLES`.`TABLE_SCHEMA` = 'myanimebot' and `information_schema`.`TABLES`.`TABLE_TYPE` = 'BASE TABLE' and (`information_schema`.`TABLES`.`TABLE_NAME` like 't\\_%' or `information_schema`.`TABLES`.`TABLE_NAME` like 'job\\_%') order by `information_schema`.`TABLES`.`TABLE_NAME`;
  620. -- Dumping structure for view myanimebot.v_ActiveUsers
  621. -- Removing temporary table and create final VIEW structure
  622. DROP TABLE IF EXISTS `v_ActiveUsers`;
  623. CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `v_ActiveUsers` AS select `t_users`.`mal_user` AS `user`,`t_users`.`service` AS `service`,case when exists(select 1 from `t_feeds` where `t_feeds`.`user` = `t_users`.`mal_user` limit 1) then '1' else '0' end AS `active` from `t_users`;
  624. -- Dumping structure for view myanimebot.v_CountFeedsType
  625. -- Removing temporary table and create final VIEW structure
  626. DROP TABLE IF EXISTS `v_CountFeedsType`;
  627. CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `v_CountFeedsType` AS select `t_feeds`.`type` AS `type`,count(`t_feeds`.`id`) AS `total` from `t_feeds` where `t_feeds`.`type` <> 'N/A' group by `t_feeds`.`type` order by count(`t_feeds`.`id`) desc;
  628. -- Dumping structure for view myanimebot.v_CountMediaType
  629. -- Removing temporary table and create final VIEW structure
  630. DROP TABLE IF EXISTS `v_CountMediaType`;
  631. CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `v_CountMediaType` AS select `t_animes`.`media` AS `media`,count(`t_animes`.`media`) AS `total` from `t_animes` group by `t_animes`.`media`;
  632. -- Dumping structure for view myanimebot.v_DailyHistory
  633. -- Removing temporary table and create final VIEW structure
  634. DROP TABLE IF EXISTS `v_DailyHistory`;
  635. CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `v_DailyHistory` AS select cast(`t_history`.`date` as date) AS `date`,max(`t_history`.`nbFeeds`) AS `nbFeeds`,max(`t_history`.`nbUniqueFeeds`) AS `nbUniqueFeeds`,max(`t_history`.`nbMedia`) AS `nbMedia`,max(`t_history`.`nbUsers`) AS `nbUsers`,max(`t_history`.`nbServers`) AS `nbServers`,round(avg(`t_history`.`nbDuplicateFeeds`),0) AS `nbDuplacteFeeds`,round(avg(`t_history`.`nbDuplicateMedia`),0) AS `nbDuplicateMedia`,round(avg(`t_history`.`nbEmptyThumbnail`),0) AS `nbEmptyThumbnail`,round(avg(`t_history`.`nbInactiveUsers`),0) AS `nbInactiveUsers`,round(avg(`t_history`.`spaceFeedsTable`),0) AS `spaceFeedsTable`,round(avg(`t_history`.`spaceAnimesTable`),0) AS `spaceAnimesTable`,round(avg(`t_history`.`spaceUsersTable`),0) AS `SpaceUsersTable`,round(avg(`t_history`.`spaceServersTable`),0) AS `SpaceServersTable`,round(avg(`t_history`.`dailyAveragePerUser`),0) AS `dailyAveragePerUser`,round(avg(`t_history`.`orphanMedias`),0) AS `orphanMedias`,round(avg(`t_history`.`nbMediaManga`),0) AS `nbMediaManga`,round(avg(`t_history`.`nbMediaAnime`),0) AS `nbMediaAnime`,round(avg(`t_history`.`nbLog`),0) AS `nbLog`,round(avg(`t_history`.`nbErrorLog`),0) AS `nbErrorLog` from `t_history` group by cast(`t_history`.`date` as date) order by cast(`t_history`.`date` as date) desc;
  636. -- Dumping structure for view myanimebot.v_Top
  637. -- Removing temporary table and create final VIEW structure
  638. DROP TABLE IF EXISTS `v_Top`;
  639. CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW `v_Top` AS select `t_feeds`.`user` AS `user`,count(`t_feeds`.`title`) AS `total` from `t_feeds` group by `t_feeds`.`user` order by count(`t_feeds`.`title`) desc;
  640. -- Dumping structure for view myanimebot.v_TopAnimes
  641. -- Removing temporary table and create final VIEW structure
  642. DROP TABLE IF EXISTS `v_TopAnimes`;
  643. CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `v_TopAnimes` AS select `t_feeds`.`title` AS `anime`,count(distinct `t_feeds`.`user`) AS `nbUser`,count(0) AS `total` from `t_feeds` group by `t_feeds`.`title` order by count(0) desc;
  644. -- Dumping structure for view myanimebot.v_TopUniqueAnimePerUsers
  645. -- Removing temporary table and create final VIEW structure
  646. DROP TABLE IF EXISTS `v_TopUniqueAnimePerUsers`;
  647. CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW `v_TopUniqueAnimePerUsers` AS select `t_feeds`.`user` AS `user`,`t_feeds`.`title` AS `title`,count(`t_feeds`.`title`) AS `count` from `t_feeds` group by `t_feeds`.`title`,`t_feeds`.`user` order by count(`t_feeds`.`title`) desc;
  648. -- Dumping structure for view myanimebot.v_TotalAnimes
  649. -- Removing temporary table and create final VIEW structure
  650. DROP TABLE IF EXISTS `v_TotalAnimes`;
  651. CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW `v_TotalAnimes` AS select count(0) AS `total` from `t_animes`;
  652. -- Dumping structure for view myanimebot.v_TotalDifferentAnimesPerUser
  653. -- Removing temporary table and create final VIEW structure
  654. DROP TABLE IF EXISTS `v_TotalDifferentAnimesPerUser`;
  655. CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW `v_TotalDifferentAnimesPerUser` AS select `t_feeds`.`user` AS `user`,count(distinct `t_feeds`.`title`) AS `total` from `t_feeds` group by `t_feeds`.`user` order by count(distinct `t_feeds`.`title`) desc;
  656. -- Dumping structure for view myanimebot.v_TotalFeeds
  657. -- Removing temporary table and create final VIEW structure
  658. DROP TABLE IF EXISTS `v_TotalFeeds`;
  659. CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW `v_TotalFeeds` AS select count(0) AS `total` from `t_feeds`;
  660. /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
  661. /*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
  662. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  663. /*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;