simplify subscribing/unsubscribing podcasts
[mygpo.git] / install / update-15.sql
blobd2cc4f07f580266ea91f72ed900757b117ab88f8
1 DROP VIEW IF EXISTS recent_unique_plays;
3 CREATE VIEW recent_unique_plays AS
4     SELECT DISTINCT user_id, episode_id
5     FROM episode_log
6     WHERE action='play'
7     AND DATEDIFF(NOW(), timestamp) <= 7;
10 DROP VIEW IF EXISTS episode_toplist;
12 CREATE VIEW episode_toplist AS
13     SELECT episode_id AS id, episode_id, count(episode_id) AS listeners
14     FROM recent_unique_plays
15     GROUP BY episode_id
16     ORDER BY listeners
17     DESC LIMIT 100;
19 CREATE TABLE IF NOT EXISTS `security_tokens` (
20     `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
21     `user_id` integer NOT NULL,
22     `token` varchar(32) NOT NULL,
23     `object` varchar(64) NOT NULL,
24     `action` varchar(10) NOT NULL