From: Steve Sutton Date: Tue, 26 Jul 2016 19:12:06 +0000 (-0400) Subject: Leads table updates for stats. X-Git-Tag: v1.0.0^2~3 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=2956fc8b709c43761428cd8118bd75f8324f2635;p=WP-Plugins%2Fglm-member-db-leads.git Leads table updates for stats. Chuck and I discussed the tables for the leads stats need to change. We're removing the original tables and using one called {prefix}lead_stats which will store the daily weekly monthly stats. Then we could very simply add more types like yearly or whatever. --- diff --git a/index.php b/index.php index 7408dbe..7e53dfd 100644 --- a/index.php +++ b/index.php @@ -38,7 +38,7 @@ * version from this plugin. */ define('GLM_MEMBERS_LEADS_PLUGIN_VERSION', '0.0.1'); -define('GLM_MEMBERS_LEADS_PLUGIN_DB_VERSION', '0.0.6'); +define('GLM_MEMBERS_LEADS_PLUGIN_DB_VERSION', '0.0.7'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_LEADS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.0.5'); diff --git a/setup/databaseScripts/create_database_V0.0.4.sql b/setup/databaseScripts/create_database_V0.0.4.sql deleted file mode 100644 index c6ed18c..0000000 --- a/setup/databaseScripts/create_database_V0.0.4.sql +++ /dev/null @@ -1,162 +0,0 @@ --- Gaslight Media Members Database - Leads --- File Created: 16/07/19 16:16:16 --- Database Version: 0.0.3 --- Database Creation Script --- --- This file is called to create a new set of tables for this --- add-on for the most receint database version for this add-on. --- --- There should only be one such file in this directory --- --- To permit each query below to be executed separately, --- all queries must be separated by a line with four dashes - - --- Leads -CREATE TABLE {prefix}leads ( - id INT NOT NULL AUTO_INCREMENT, - email TINYTEXT NULL, -- Email address of lead - mail_ok BOOLEAN NULL, -- OK to send them E-Mail - member_ok BOOLEAN NULL, -- OK to have members contact lead - created DATETIME NULL, -- Timestamp lead was first added - PRIMARY KEY (id), - INDEX (email(20)) -); - ----- - --- Sources - info on form or method via which lead can be submitted -CREATE TABLE {prefix}sources ( - id INT NOT NULL AUTO_INCREMENT, - title TINYTEXT NULL, -- Title/Name of source for reference - code TINYTEXT NULL, -- Code supplied by form to indicate source - form_id INT NULL, - enabled BOOLEAN NULL, - PRIMARY KEY (id), - INDEX (code(20)) -); - ----- - --- Lead Entry - Information on a single submission of lead information -CREATE TABLE {prefix}lead_entry ( - id INT NOT NULL AUTO_INCREMENT, - source_id SMALLINT NULL, -- Pointer to sources entry - Form used to submit lead data - lead_id INTEGER NULL, -- Pointer to lead - all submissions for same E-Mail address point to same leads entry - gf_entry_id INTEGER NULL, -- Reference to Gravity Form Entry - fname TINYTEXT NULL, -- First Name - lname TINYTEXT NULL, -- Last Name - org TINYTEXT NULL, -- Organization name - addr1 TINYTEXT NULL, -- Address line 1 - addr2 TINYTEXT NULL, -- Address line 2 - city TINYTEXT NULL, -- City name - state TINYTEXT NULL, -- State/Province - as submitted by Gravityforms or whatever (not state code) - zip TINYTEXT NULL, -- ZIP/Postal code - country TINYTEXT NULL, -- Country name - as submitted by form (not country code) - phone TINYTEXT NULL, -- Primary phone # - phone2 TINYTEXT NULL, -- Alternate phone # - fax TINYTEXT NULL, -- Fax # - how_heard SMALLINT NULL, -- Pointer to how_heard table entry - visit_date DATE NULL, -- Anticipated date of visit - date_submitted DATE NULL, -- Date this information was submitted - user_trace_info TINYTEXT NULL, -- User IP address and other identifying network info (pos referrer) - PRIMARY KEY (id), - INDEX (source_id), - INDEX (lead_id), - INDEX (fname(20)), - INDEX (lname(20)), - INDEX (visit_date), - INDEX (date_submitted) -); - ----- - --- Interest Groups -CREATE TABLE {prefix}interest_groups ( - id INT NOT NULL AUTO_INCREMENT, - title TINYTEXT NULL, -- Group name - members BOOLEAN DEFAULT '0', - PRIMARY KEY (id) -); - ----- - --- Interests - Used to build Interest fields in forms - Forms use ID as value -CREATE TABLE {prefix}interests ( - id INT NOT NULL AUTO_INCREMENT, - title TINYTEXT NULL, -- Title - group_id SMALLINT NULL, -- Pointer to interest group - PRIMARY KEY (id), - INDEX (group_id) -); - ----- - --- GF Interests - Used to relate the Gravity Form field id for interests -CREATE TABLE {prefix}gf_interests ( - id INT NOT NULL AUTO_INCREMENT, - interest_id INTEGER NULL, -- Id for the interests - gf_field_id TINYTEXT NULL, -- The field id from gravity forms for this interest - form_id INT NULL, -- The Gravity Form Id - PRIMARY KEY (id), - INDEX (gf_field_id(6)), - INDEX (interest_id), - INDEX (form_id) -); - ----- - --- Lead Interests - many to one links to lead-entry table -CREATE TABLE {prefix}lead_interests ( - id INT NOT NULL AUTO_INCREMENT, - interest_id SMALLINT NULL, -- Pointer to Interest table - lead_entry_id INTEGER NULL, -- Pointer to lead_entry table - PRIMARY KEY (id), - INDEX (interest_id), - INDEX (lead_entry_id) -); - ----- - --- lead_searches - Memorized search configurations -CREATE TABLE {prefix}searches ( - id INT NOT NULL AUTO_INCREMENT, - user_id INT NOT NULL, -- The wordpress user id - title TINYTEXT NULL, -- Title for this search configuration - search TEXT NULL, -- Serialized array of search parameters - date_created DATE NULL, -- Date the search type was created - PRIMARY KEY (id) -); - ----- - --- Lead Stats Date Data - Totals of lead stats for 1 day - Preserved for 2 years -CREATE TABLE {prefix}lead_stats_date ( - id INT NOT NULL AUTO_INCREMENT, - stat_date DATE NULL, -- Date for which these stats are accumulated - leads_count INTEGER NULL, -- Number of leads - PRIMARY KEY (id), - INDEX (stat_date) -); - ----- - --- Lead Stats Week Data - Totals of lead stats for 1 week - Preserved for 2 years - (generated daily?) -CREATE TABLE {prefix}lead_stats_week ( - id INT NOT NULL AUTO_INCREMENT, - stat_week DATE NULL, -- First date of week for which these stats are accumulated - leads_count INTEGER NULL, -- Number of leads - PRIMARY KEY (id), - INDEX (stat_week) -); - ----- - --- Lead Stats Month Data - Totals of lead stats for 1 month - Preserved indefinately - (generated daily?) -CREATE TABLE {prefix}lead_stats_month ( - id INT NOT NULL AUTO_INCREMENT, - stat_month DATE NULL, -- First date of month for which these stats are accumulated - leads_count INTEGER NULL, -- Number of leads - PRIMARY KEY (id), - INDEX (stat_month) -); diff --git a/setup/databaseScripts/create_database_V0.0.7.sql b/setup/databaseScripts/create_database_V0.0.7.sql new file mode 100644 index 0000000..cee28fa --- /dev/null +++ b/setup/databaseScripts/create_database_V0.0.7.sql @@ -0,0 +1,142 @@ +-- Gaslight Media Members Database - Leads +-- File Created: 16/07/19 16:16:16 +-- Database Version: 0.0.3 +-- Database Creation Script +-- +-- This file is called to create a new set of tables for this +-- add-on for the most recent database version for this add-on. +-- +-- There should only be one such file in this directory +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + + +-- Leads +CREATE TABLE {prefix}leads ( + id INT NOT NULL AUTO_INCREMENT, + email TINYTEXT NULL, -- Email address of lead + mail_ok BOOLEAN NULL, -- OK to send them E-Mail + member_ok BOOLEAN NULL, -- OK to have members contact lead + created DATETIME NULL, -- Timestamp lead was first added + PRIMARY KEY (id), + INDEX (email(20)) +); + +---- + +-- Sources - info on form or method via which lead can be submitted +CREATE TABLE {prefix}sources ( + id INT NOT NULL AUTO_INCREMENT, + title TINYTEXT NULL, -- Title/Name of source for reference + code TINYTEXT NULL, -- Code supplied by form to indicate source + form_id INT NULL, + enabled BOOLEAN NULL, + PRIMARY KEY (id), + INDEX (code(20)) +); + +---- + +-- Lead Entry - Information on a single submission of lead information +CREATE TABLE {prefix}lead_entry ( + id INT NOT NULL AUTO_INCREMENT, + source_id SMALLINT NULL, -- Pointer to sources entry - Form used to submit lead data + lead_id INTEGER NULL, -- Pointer to lead - all submissions for same E-Mail address point to same leads entry + gf_entry_id INTEGER NULL, -- Reference to Gravity Form Entry + fname TINYTEXT NULL, -- First Name + lname TINYTEXT NULL, -- Last Name + org TINYTEXT NULL, -- Organization name + addr1 TINYTEXT NULL, -- Address line 1 + addr2 TINYTEXT NULL, -- Address line 2 + city TINYTEXT NULL, -- City name + state TINYTEXT NULL, -- State/Province - as submitted by Gravityforms or whatever (not state code) + zip TINYTEXT NULL, -- ZIP/Postal code + country TINYTEXT NULL, -- Country name - as submitted by form (not country code) + phone TINYTEXT NULL, -- Primary phone # + phone2 TINYTEXT NULL, -- Alternate phone # + fax TINYTEXT NULL, -- Fax # + how_heard SMALLINT NULL, -- Pointer to how_heard table entry + visit_date DATE NULL, -- Anticipated date of visit + date_submitted DATE NULL, -- Date this information was submitted + user_trace_info TINYTEXT NULL, -- User IP address and other identifying network info (pos referrer) + PRIMARY KEY (id), + INDEX (source_id), + INDEX (lead_id), + INDEX (fname(20)), + INDEX (lname(20)), + INDEX (visit_date), + INDEX (date_submitted) +); + +---- + +-- Interest Groups +CREATE TABLE {prefix}interest_groups ( + id INT NOT NULL AUTO_INCREMENT, + title TINYTEXT NULL, -- Group name + members BOOLEAN DEFAULT '0', + PRIMARY KEY (id) +); + +---- + +-- Interests - Used to build Interest fields in forms - Forms use ID as value +CREATE TABLE {prefix}interests ( + id INT NOT NULL AUTO_INCREMENT, + title TINYTEXT NULL, -- Title + group_id SMALLINT NULL, -- Pointer to interest group + PRIMARY KEY (id), + INDEX (group_id) +); + +---- + +-- GF Interests - Used to relate the Gravity Form field id for interests +CREATE TABLE {prefix}gf_interests ( + id INT NOT NULL AUTO_INCREMENT, + interest_id INTEGER NULL, -- Id for the interests + gf_field_id TINYTEXT NULL, -- The field id from gravity forms for this interest + form_id INT NULL, -- The Gravity Form Id + PRIMARY KEY (id), + INDEX (gf_field_id(6)), + INDEX (interest_id), + INDEX (form_id) +); + +---- + +-- Lead Interests - many to one links to lead-entry table +CREATE TABLE {prefix}lead_interests ( + id INT NOT NULL AUTO_INCREMENT, + interest_id SMALLINT NULL, -- Pointer to Interest table + lead_entry_id INTEGER NULL, -- Pointer to lead_entry table + PRIMARY KEY (id), + INDEX (interest_id), + INDEX (lead_entry_id) +); + +---- + +-- lead_searches - Memorized search configurations +CREATE TABLE {prefix}searches ( + id INT NOT NULL AUTO_INCREMENT, + user_id INT NOT NULL, -- The wordpress user id + title TINYTEXT NULL, -- Title for this search configuration + search TEXT NULL, -- Serialized array of search parameters + date_created DATE NULL, -- Date the search type was created + PRIMARY KEY (id) +); + +---- + +-- Lead Stats Data - Totals of lead stats - Preserved for 2 years +CREATE TABLE {prefix}lead_stats ( + id INT NOT NULL AUTO_INCREMENT, + stat_type TINYTEXT NULL, -- Type of stat Daily, Weekly, Monthly... + stat_date DATE NULL, -- Date for which these stats are accumulated + leads_count INTEGER NULL, -- Number of leads + PRIMARY KEY (id), + INDEX (stat_type(10)), + INDEX (stat_date) +); diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 7ffdae4..5452f62 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -20,5 +20,6 @@ $glmMembersLeadsDbVersions = array( '0.0.4' => array('version' => '0.0.4', 'tables' => 10, 'date' => '7/21/2016'), '0.0.5' => array('version' => '0.0.5', 'tables' => 10, 'date' => '7/22/2016'), '0.0.6' => array('version' => '0.0.6', 'tables' => 11, 'date' => '7/22/2016'), + '0.0.7' => array('version' => '0.0.7', 'tables' => 9, 'date' => '7/26/2016'), ); diff --git a/setup/databaseScripts/update_database_V0.0.7.sql b/setup/databaseScripts/update_database_V0.0.7.sql new file mode 100644 index 0000000..c903bd3 --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.7.sql @@ -0,0 +1,33 @@ +-- Gaslight Media Members Database - Events Add-On +-- File Created: 16/07/19 16:16:16 +-- Database Version: 0.0.3 +-- Database Update From Previous Version Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Lead Stats Data - Totals of lead stats - Preserved for 2 years +CREATE TABLE {prefix}lead_stats ( + id INT NOT NULL AUTO_INCREMENT, + stat_type TINYTEXT NULL, -- Type of stat Daily, Weekly, Monthly... + stat_date DATE NULL, -- Date for which these stats are accumulated + leads_count INTEGER NULL, -- Number of leads + PRIMARY KEY (id), + INDEX (stat_type(10)), + INDEX (stat_date) +); + +---- + +-- Drop table +DROP TABLE {prefix}lead_stats_date; + +---- + +-- Drop table +DROP TABLE {prefix}lead_stats_week; + +---- + +-- Drop table +DROP TABLE {prefix}lead_stats_month;