Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
Normalised the database, and refactored the reporting to allow it to …
Browse files Browse the repository at this point in the history
…support multiple dbs.
  • Loading branch information
markmandel committed Nov 5, 2011
1 parent 4b74b34 commit e79ffc5
Show file tree
Hide file tree
Showing 10 changed files with 399 additions and 336 deletions.
85 changes: 55 additions & 30 deletions db/mysql-alter.sql
@@ -1,30 +1,55 @@
ALTER TABLE `squabble_visitors`
ADD INDEX `idx_test_name` (`test_name` ASC) ;

delete
from
squabble_combinations
where
visitor_id NOT IN (select squabble_visitors.id from squabble_visitors);

ALTER TABLE `squabble_combinations`
ADD CONSTRAINT `fk_combination_visitor_id`
FOREIGN KEY (`visitor_id` )
REFERENCES `squabble_visitors` (`id` )
ON DELETE RESTRICT
ON UPDATE RESTRICT
, ADD INDEX `fk_combination_visitor_id` (`visitor_id` ASC) ;

ALTER TABLE `squabble_conversions`
ADD CONSTRAINT `fk_conversion_visitor_id`
FOREIGN KEY (`visitor_id` )
REFERENCES `squabble_visitors` (`id` )
ON DELETE RESTRICT
ON UPDATE RESTRICT
, ADD INDEX `fk_conversion_visitor_id` (`visitor_id` ASC) ;

ALTER TABLE `squabble_conversions`
CHANGE `conversion_revenue` `conversion_value` double;

ALTER TABLE `squabble_conversions`
ADD `conversion_units` DOUBLE AFTER `conversion_value`;
/*
Copyright 2011 Ezra Parker, Josh Wines, Mark Mandel
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Squabble Database Create Script (MySQL with InnoDB)
*/

ALTER TABLE `squabble_visitors` ADD COLUMN `flat_combination` VARCHAR(1000) NOT NULL AFTER `test_name`
, ADD INDEX `idx_flat_combination` (`flat_combination` ASC) ;

drop table if exists temp_visitor_data ;

create table temp_visitor_data (
`id` char(35) ,
flat_combination varchar(1000)
,PRIMARY KEY (`id`)
)
;

insert into temp_visitor_data
(id, flat_combination)
SELECT
squabble_visitors.id,
GROUP_CONCAT(squabble_combinations.variation_name ORDER BY squabble_combinations.section_name) AS combination
FROM
squabble_visitors
INNER JOIN
squabble_combinations
ON squabble_combinations.visitor_id = squabble_visitors.id
group by
squabble_visitors.id
;

update
squabble_visitors, temp_visitor_data
set
squabble_visitors.flat_combination = temp_visitor_data.flat_combination
where
squabble_visitors.id = temp_visitor_data.id;
and
squabble_visitors.flat_combination is null

drop table if exists temp_visitor_data ;
13 changes: 8 additions & 5 deletions db/mysql-create.sql
Expand Up @@ -19,9 +19,9 @@

-- MySQL dump 10.13 Distrib 5.1.41, for debian-linux-gnu (x86_64)
--
-- Host: jiffyshirts Database: squabble
-- Host: squabble Database: squabble
-- ------------------------------------------------------
-- Server version 5.1.41-3ubuntu12.10-log
-- Server version 5.1.41-3ubuntu12.10

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
Expand Down Expand Up @@ -63,7 +63,8 @@ CREATE TABLE `squabble_conversions` (
`visitor_id` char(35) DEFAULT NULL,
`conversion_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`conversion_name` varchar(500) NOT NULL,
`conversion_revenue` double DEFAULT NULL,
`conversion_value` double DEFAULT NULL,
`conversion_units` double DEFAULT NULL,
KEY `fk_conversion_visitor_id` (`visitor_id`),
CONSTRAINT `fk_conversion_visitor_id` FOREIGN KEY (`visitor_id`) REFERENCES `squabble_visitors` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Expand All @@ -80,8 +81,10 @@ CREATE TABLE `squabble_visitors` (
`id` char(35) NOT NULL,
`visit_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`test_name` varchar(500) NOT NULL,
`flat_combination` varchar(1000) NOT NULL,
PRIMARY KEY (`id`),
KEY `idx_test_name` (`test_name`)
KEY `idx_test_name` (`test_name`),
KEY `idx_flat_combination` (`flat_combination`(767))
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
Expand All @@ -94,4 +97,4 @@ CREATE TABLE `squabble_visitors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2011-06-03 12:02:29
-- Dump completed on 2011-11-05 15:18:00
5 changes: 5 additions & 0 deletions docs/gen/colddoc/run.cfm
Expand Up @@ -22,6 +22,11 @@
base = expandPath("../../../squabble");
path = expandPath("../../api/squabble");
if(directoryExists(path))
{
directoryDelete(path, true);
}
colddoc = createObject("component", "colddoc.ColdDoc").init();
strategy = createObject("component", "colddoc.strategy.api.HTMLAPIStrategy").init(path, "Squabble");
colddoc.setStrategy(strategy);
Expand Down

0 comments on commit e79ffc5

Please sign in to comment.