Skip to content

Commit

Permalink
fixing bug in referring search term data migration
Browse files Browse the repository at this point in the history
adding session source data migrations for organic-search and referral
  • Loading branch information
padams committed Jul 5, 2010
1 parent c288ac0 commit e970422
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
39 changes: 37 additions & 2 deletions modules/base/updates/005.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ function up() {
"INSERT
owa_search_term_dim (id, terms, term_count)
SELECT
(CRC32(LOWER(query_terms))) as id,
distinct(CRC32(LOWER(query_terms))) as id,
query_terms as terms,
SUM( LENGTH(query_terms) - LENGTH(REPLACE(query_terms, ' ', ''))+1) as term_count
length(query_terms) + 1 - length(replace(query_terms,' ','')) as term_count
FROM
owa_referer
WHERE
Expand Down Expand Up @@ -172,6 +172,41 @@ function up() {
return false;
}

//populate search source in session table
$ret = $db->query(
"UPDATE
owa_session as session
SET
session.source = 'organic-search'
WHERE
session.referring_search_term_id IS NOT null"
);

if (!$ret) {
$this->e->notice('Failed to populate session.source values for organic-search');
return false;
}

//populate search source in session table
$ret = $db->query(
"UPDATE
owa_session as session
SET
session.source = 'referral'
WHERE
session.referer_id != 0 AND
session.referer_id != '' AND
session.referer_id != null AND
session.source != 'feed' AND
session.source != 'organic-search'"
);

if (!$ret) {
$this->e->notice('Failed to populate session.source values for referral');
return false;
}


// add apiKeys to each user
$users = $db->get_results("select user_id from owa_user");

Expand Down
6 changes: 3 additions & 3 deletions owa_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,10 @@ function &singleton($class_dir, $class_prefix, $class_name, $conf = array()) {

static $instance;

if (!isset($instance)):
if (!isset($instance)) {
// below missing a reference becasue the static vriable can not handle a reference
$instance = owa_lib::factory($class_dir, $class_prefix, $class_name, $conf = array());
endif;
$instance = owa_lib::factory($class_dir, $class_prefix, $class_name, $conf);
}

return $instance;
}
Expand Down

0 comments on commit e970422

Please sign in to comment.