r99538 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99537‎ | r99538 | r99539 >
Date:19:12, 11 October 2011
Author:catrope
Status:ok
Tags:
Comment:
Contest: Fix SQL file. Clean up and add comments, rename indexes to include table name, and drop a redundant index on vote_contestant_id
Modified paths:
  • /trunk/extensions/Contest/Contest.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.sql
@@ -6,8 +6,8 @@
77 CREATE TABLE IF NOT EXISTS /*_*/contests (
88 contest_id SMALLINT unsigned NOT NULL auto_increment PRIMARY KEY,
99 contest_name VARCHAR(255) NOT NULL, -- String indentifier for the contest
10 - contest_status TINYINT unsigned NOT NULL default '0', -- Status of the contest
11 - contest_end varbinary(14) NOT NULL default '', -- End time of the contest
 10+ contest_status TINYINT unsigned NOT NULL default '0', -- Status of the contest. One of 0 (DRAFT), 1 (ACTIVE), 2 (FINISHED)
 11+ contest_end varbinary(14) NOT NULL default '', -- End time of the contest (MW timestamp)
1212
1313 contest_rules_page VARCHAR(255) NOT NULL, -- Name of the page with rules
1414 contest_opportunities VARCHAR(255) NOT NULL, -- Name of the page with opportunities
@@ -16,10 +16,10 @@
1717 contest_signup_email VARCHAR(255) NOT NULL, -- Name of the page with the signup email text
1818 contest_reminder_email VARCHAR(255) NOT NULL, -- Name of the page with the reminder email text
1919
20 - contest_submission_count SMALLINT unsigned NOT NULL-- Amount of submissions made to the contest
 20+ contest_submission_count SMALLINT unsigned NOT NULL -- Number of submissions made to the contest
2121 ) /*$wgDBTableOptions*/;
22 -CREATE UNIQUE INDEX /*i*/contest_name ON /*_*/contests (contest_name);
23 -CREATE INDEX /*i*/contest_status ON /*_*/contests (contest_status, contest_end);
 22+CREATE UNIQUE INDEX /*i*/contests_name ON /*_*/contests (contest_name);
 23+CREATE INDEX /*i*/contests_status_end ON /*_*/contests (contest_status, contest_end);
2424
2525 -- Contestants
2626 CREATE TABLE IF NOT EXISTS /*_*/contest_contestants (
@@ -35,19 +35,20 @@
3636
3737 -- Extra contestant info
3838 contestant_country VARCHAR(255) NOT NULL, -- Country code of the contestant
39 - contestant_volunteer TINYINT unsigned NOT NULL, -- If the user is interested in voluneer oportunities
 39+ contestant_volunteer TINYINT unsigned NOT NULL, -- If the user is interested in volunteer opportunities
4040 contestant_wmf TINYINT unsigned NOT NULL, -- If the user is interested in a WMF job
4141 contestant_cv TINYBLOB NOT NULL, -- URL to the users CV
4242
4343 contestant_submission TINYBLOB NOT NULL, -- URL to the users submission
4444
45 - contestant_rating TINYINT unsigned NOT NULL, -- The avarage rating of the contestant
46 - contestant_rating_count SMALLINT unsigned NOT NULL, -- The amount of ratings
47 - contestant_comments SMALLINT unsigned NOT NULL -- The amount of comments
 45+ contestant_rating TINYINT unsigned NOT NULL, -- The average rating of the contestant
 46+ contestant_rating_count SMALLINT unsigned NOT NULL, -- The number of ratings
 47+ contestant_comments SMALLINT unsigned NOT NULL -- The number of comments
4848 ) /*$wgDBTableOptions*/;
49 -CREATE INDEX /*i*/contestant_interests ON /*_*/contest_contestants (contestant_challenge_id, contestant_wmf, contestant_volunteer);
50 -CREATE INDEX /*i*/contestant_rating ON /*_*/contest_contestants (contestant_challenge_id, contestant_rating, contestant_rating_count);
51 -CREATE UNIQUE INDEX /*i*/contestant_user_contest ON /*_*/contest_contestants (contestant_contest_id, contestant_user_id);
 49+-- TODO: probably need to split indexes, see queries in ContestantPager
 50+CREATE INDEX /*i*/contest_contestants_interests ON /*_*/contest_contestants (contestant_challenge_id, contestant_wmf, contestant_volunteer);
 51+CREATE INDEX /*i*/contest_contestants_rating ON /*_*/contest_contestants (contestant_challenge_id, contestant_rating, contestant_rating_count);
 52+CREATE UNIQUE INDEX /*i*/contest_contestants_id_user ON /*_*/contest_contestants (contestant_contest_id, contestant_user_id);
5253
5354 -- Challenges
5455 CREATE TABLE IF NOT EXISTS /*_*/contest_challenges (
@@ -58,8 +59,8 @@
5960 challenge_title VARCHAR(255) NOT NULL, -- Title of the challenge
6061 challenge_oneline TEXT NOT NULL -- One line description of the challenge
6162 ) /*$wgDBTableOptions*/;
62 -CREATE INDEX /*i*/challenge_contest_id ON /*_*/contest_challenges (challenge_contest_id);
63 -CREATE UNIQUE INDEX /*i*/challenge_title ON /*_*/contest_challenges (challenge_title);
 63+CREATE INDEX /*i*/contest_challenges_contest_id ON /*_*/contest_challenges (challenge_contest_id);
 64+CREATE UNIQUE INDEX /*i*/contest_challenges_title ON /*_*/contest_challenges (challenge_title);
6465
6566 -- Judge votes
6667 CREATE TABLE IF NOT EXISTS /*_*/contest_votes (
@@ -69,9 +70,8 @@
7071
7172 vote_value SMALLINT NOT NULL -- The value of the vote
7273 ) /*$wgDBTableOptions*/;
73 -CREATE INDEX /*i*/vote_contestant_id ON /*_*/contest_votes (vote_contestant_id);
74 -CREATE UNIQUE INDEX /*i*/vote_contestant_user ON /*_*/contest_votes (vote_contestant_id, vote_user_id);
75 -CREATE INDEX /*i*/vote_user_id ON /*_*/contest_votes (vote_user_id);
 74+CREATE UNIQUE INDEX /*i*/contest_votes_contestant_user ON /*_*/contest_votes (vote_contestant_id, vote_user_id);
 75+CREATE INDEX /*i*/contest_votes_user ON /*_*/contest_votes (vote_user_id);
7676
7777 -- Judge comments
7878 CREATE TABLE IF NOT EXISTS /*_*/contest_comments (
@@ -82,4 +82,4 @@
8383 comment_text TEXT NOT NULL, -- The comment text
8484 comment_time varbinary(14) NOT NULL default '' -- The time at which the comment was made
8585 ) /*$wgDBTableOptions*/;
86 -CREATE INDEX /*i*/comment_time ON /*_*/contest_comments (comment_contestant_id, comment_time);
\ No newline at end of file
 86+CREATE INDEX /*i*/contest_comments_id_time ON /*_*/contest_comments (comment_contestant_id, comment_time);

Status & tagging log