Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for scheduling events (specials) and announcements in the database #240

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sfk-steelsong
Copy link
Contributor

adds two new tables: events and eventtype

SQL is at the end.

be careful because "events" is a reserved word and may cause anger if not wrapped in quotes. works on my machine but please double check :). Tried to keep it vague so we can use the table for other scheduled stuff (double exp weekends?). It supports multiple sets of specials active at one time if that happens (holiday and milestone pet, for example). You'll still need to add info on the specials in the list object in the json file but now we can deploy them early and schedule them to go live later.

Also, using adate on announcement for when the announcement should be available; current behaviour is preserved in that if you don't put a date it'll go live immediately like it already does, but if you put a date in the future it won't show up until after that time has passed.

SQL:

table creation:

DROP TABLE IF EXISTS `eventtype`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `eventtype` (
	`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
	`type` varchar(25) NOT NULL,
	PRIMARY KEY (`id`),
	UNIQUE KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

DROP TABLE IF EXISTS `events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `events` (
	`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
	`eventtype` varchar(25) NOT NULL,
	`starttime` timestamp NOT NULL DEFAULT '2001-01-01 08:00:00',
	`endtime` timestamp NOT NULL DEFAULT '2001-01-01 08:00:00',
	`config` varchar(1500) DEFAULT NULL,
	PRIMARY KEY (`id`),
    KEY `typeandtime` (`eventtype`, `starttime`, `endtime`),
	CONSTRAINT `event_ibfk_1` FOREIGN KEY (`eventtype`) REFERENCES `eventtype` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

type table data contents:

INSERT INTO `eventtype` (`type`) VALUES ('SPECIAL');

Example event data (config based on an attempt to reverse engineer the contents of specialRate in the json file since I don't have a sample):

INSERT INTO `events` (eventtype, starttime, endtime, config) values ('SPECIAL', NOW(), date_add(NOW(), INTERVAL 1 HOUR), '[{"animal":":mouse2:", "rate":0.1},{"animal":":baby_chick:", "rate":0.1}]');
INSERT INTO `events` (eventtype, starttime, endtime, config) values ('SPECIAL', NOW(), date_add(NOW(), INTERVAL 1 HOUR), '[{"animal":":sheep:", "rate":0.1},{"animal":":pig2:", "rate":0.1}]');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant