<commit_before>SET character_set_client = utf8;

CREATE DATABASE IF NOT EXISTS pattsdb;

USE pattsdb;

CREATE TABLE IF NOT EXISTS User
(
	`dbUser` VARCHAR(8) CHARACTER SET utf8 NOT NULL,
 	`state` BIT NOT NULL,
	`isAdmin` BIT NOT NULL,
	`firstName` VARCHAR(45) CHARACTER SET utf8 NOT NULL,
	`middleName` VARCHAR(45) CHARACTER SET utf8 NOT NULL,
	`lastName` VARCHAR(45) CHARACTER SET utf8 NOT NULL,
	PRIMARY KEY (`dbUser`)
);

CREATE TABLE IF NOT EXISTS TaskType
(
	`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
	`state` BIT NOT NULL,
	`parentID` INT UNSIGNED NOT NULL,
	`displayName` VARCHAR(45) CHARACTER SET utf8 NOT NULL,
	PRIMARY KEY (`id`)
);

CREATE TABLE IF NOT EXISTS TaskItem
(
	`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
	`state` BIT NOT NULL,
	`onClock` BIT NOT NULL,
	`typeID` INT UNSIGNED NOT NULL,
	`userID` VARCHAR(8) NOT NULL,
	`startTime` DATETIME NOT NULL,
	`stopTime` DATETIME NULL,
	PRIMARY KEY(`id`)
);

CREATE PROCEDURE clockIn (taskID INT UNSIGNED, username VARCHAR(8))
BEGIN
	INSERT INTO TaskItem(state,onClock,startTime,typeID,userID)
	       VALUES(1,1,NOW(),taskID,username);
END

CREATE PROCEDURE clockOut (taskID INT UNSIGNED)
BEGIN
	-- need to declare local variable username here equal to userID from
	-- the TaskItem with the id of taskID

	UPDATE TaskItem SET onClock=0,stopTime=NOW()
	       WHERE id=taskID AND userID=username;
END

CREATE PROCEDURE createUser (
       newUser VARCHAR(8),
       host VARCHAR(45),
       passwd VARCHAR(45)
       )
BEGIN
	GRANT SELECT ON * TO newUser@host IDENTIFIED BY passwd;
	INSERT INTO User(state,isAdmin,dbUser,firstName,middleName,lastName)
	       VALUES(1,0,newUser,'','','');
	FLUSH PRIVILEGES;
END<commit_msg>Completed TODO<commit_after>SET character_set_client = utf8;

CREATE DATABASE IF NOT EXISTS pattsdb;

USE pattsdb;

CREATE TABLE IF NOT EXISTS User
(
	`dbUser` VARCHAR(8) CHARACTER SET utf8 NOT NULL,
 	`state` BIT NOT NULL,
	`isAdmin` BIT NOT NULL,
	`firstName` VARCHAR(45) CHARACTER SET utf8 NOT NULL,
	`middleName` VARCHAR(45) CHARACTER SET utf8 NOT NULL,
	`lastName` VARCHAR(45) CHARACTER SET utf8 NOT NULL,
	PRIMARY KEY (`dbUser`)
);

CREATE TABLE IF NOT EXISTS TaskType
(
	`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
	`state` BIT NOT NULL,
	`parentID` INT UNSIGNED NOT NULL,
	`displayName` VARCHAR(45) CHARACTER SET utf8 NOT NULL,
	PRIMARY KEY (`id`)
);

CREATE TABLE IF NOT EXISTS TaskItem
(
	`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
	`state` BIT NOT NULL,
	`onClock` BIT NOT NULL,
	`typeID` INT UNSIGNED NOT NULL,
	`userID` VARCHAR(8) NOT NULL,
	`startTime` DATETIME NOT NULL,
	`stopTime` DATETIME NULL,
	PRIMARY KEY(`id`)
);

CREATE PROCEDURE clockIn (taskID INT UNSIGNED, username VARCHAR(8))
BEGIN
	INSERT INTO TaskItem(state,onClock,startTime,typeID,userID)
	       VALUES(1,1,NOW(),taskID,username);
END

CREATE PROCEDURE clockOut (taskID INT UNSIGNED)
BEGIN
	DECLARE @username VARCHAR(8);
	SELECT @username = userID FROM TaskItem WHERE id=taskID;

	UPDATE TaskItem SET onClock=0,stopTime=NOW()
	       WHERE id=taskID AND userID=@username;
END

CREATE PROCEDURE createUser (
       newUser VARCHAR(8),
       host VARCHAR(45),
       passwd VARCHAR(45)
       )
BEGIN
	GRANT SELECT ON * TO newUser@host IDENTIFIED BY passwd;
	INSERT INTO User(state,isAdmin,dbUser,firstName,middleName,lastName)
	       VALUES(1,0,newUser,'','','');
	FLUSH PRIVILEGES;
END
{'fraction_non_alphanumeric': 0.0968414779499404, 'fraction_numerical': 0.016388557806912993, 'mean_word_length': 4.661045531197302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '626391', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1181, 'n_words': 388}