chore(web): update definition of groups_assignments
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2022-10-22 06:34:12 +08:00
parent 892a56a881
commit f044ab8ed7
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
4 changed files with 8 additions and 5 deletions

View File

@ -455,11 +455,10 @@ CREATE TABLE `groups` (
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `groups_assignments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`list_id` int(11) NOT NULL,
`group_id` int(11) NOT NULL,
`list_id` int(11) NOT NULL,
`end_time` datetime NOT NULL,
PRIMARY KEY (`id`)
PRIMARY KEY (`group_id`, `list_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

View File

@ -146,10 +146,10 @@ function queryGroupCurrentAC($group_id) {
return DB::selectAll("select a.problem_id as problem_id, a.submitter as submitter, a.submission_id as submission_id, b.submit_time as submit_time, d.title as problem_title, b.submit_time as submit_time, e.realname as realname from best_ac_submissions a inner join submissions b on (a.submission_id = b.id) inner join groups_users c on (a.submitter = c.username and c.group_id = $group_id) inner join problems d on (a.problem_id = d.id and d.is_hidden = 0) inner join user_info e on (a.submitter = e.username) where b.submit_time > addtime(now(), '-360:00:00') order by b.submit_time desc limit 10", MYSQLI_ASSOC);
}
function queryGroupAssignments($group_id) {
return DB::selectAll("select a.id as id, a.list_id as list_id, a.end_time as end_time, b.title from groups_assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id order by a.end_time asc", MYSQLI_ASSOC);
return DB::selectAll("select a.list_id as list_id, a.end_time as end_time, b.title from groups_assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id order by a.end_time asc", MYSQLI_ASSOC);
}
function queryGroupActiveAssignments($group_id) {
return DB::selectAll("select a.id as id, a.group_id as group_id, a.list_id as list_id, a.end_time as end_time, b.title from groups_assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id and a.end_time >= addtime(now(), '-168:00:00') order by a.end_time asc", MYSQLI_ASSOC);
return DB::selectAll("select a.group_id as group_id, a.list_id as list_id, a.end_time as end_time, b.title from groups_assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id and a.end_time >= addtime(now(), '-168:00:00') order by a.end_time asc", MYSQLI_ASSOC);
}
function queryAssignmentByGroupListID($group_id, $list_id) {
return DB::selectFirst("select * from groups_assignments where list_id='$list_id' and group_id='$group_id'", MYSQLI_ASSOC);

View File

@ -1,4 +1,6 @@
RENAME TABLE groups_assignments TO assignments;
ALTER TABLE `assignments` ADD COLUMN `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `assignments` DROP PRIMARY KEY, ADD PRIMARY KEY (`id`);
ALTER TABLE `assignments` ADD COLUMN `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE `assignments` CHANGE COLUMN `end_time` `deadline` datetime NOT NULL;
ALTER TABLE `countdowns` CHANGE COLUMN `end_time` `endtime` datetime NOT NULL;

View File

@ -1,4 +1,6 @@
RENAME TABLE assignments TO groups_assignments;
ALTER TABLE `assignments` DROP PRIMARY KEY, ADD PRIMARY KEY (`group_id`, `list_id`);
ALTER TABLE `assignments` DROP COLUMN `id`;
ALTER TABLE `groups_assignments` DROP COLUMN `create_time`;
ALTER TABLE `groups_assignments` CHANGE COLUMN `deadline` `end_time` datetime NOT NULL;
ALTER TABLE `countdowns` CHANGE COLUMN `endtime` `end_time` datetime NOT NULL;