Skip to content

Commit

Permalink
User primary key as index for online sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Sep 20, 2023
1 parent fc9b415 commit b8b8aa5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
12 changes: 3 additions & 9 deletions classes/erlhcoreclassmodelesonlinesession.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,15 @@ public function __get($var)
case 'time_front':
$this->time_front = date('Ymd') == date('Ymd', $this->time / 1000) ? date(erLhcoreClassModule::$dateHourFormat, $this->time / 1000) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time / 1000);
return $this->time_front;
;
break;


case 'lactivity_front':
$this->lactivity_front = date('Ymd') == date('Ymd', $this->lactivity / 1000) ? date(erLhcoreClassModule::$dateHourFormat, $this->lactivity / 1000) : date(erLhcoreClassModule::$dateDateHourFormat, $this->lactivity / 1000);
return $this->lactivity_front;
;
break;


case 'duration_front':
$this->duration_front = erLhcoreClassChat::formatSeconds($this->duration);
return $this->duration_front;
;
break;


default:
break;
}
Expand Down
5 changes: 3 additions & 2 deletions classes/lhelasticsearchindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public static function indexOs($params)
}

$sparams = array();
$sparams['body']['query']['bool']['must'][]['terms']['os_id'] = array_keys($params['items']);
$sparams['body']['query']['bool']['must'][]['terms']['_id'] = array_keys($params['items']);
$sparams['limit'] = 1000;
$documents = erLhcoreClassModelESOnlineSession::getList($sparams, array('date_index' => array('gte' => min($dateRange), 'lte' => max($dateRange))));

Expand All @@ -293,6 +293,7 @@ public static function indexOs($params)
$osLog = $documentsReindexed[$keyValue];
} else {
$osLog = new erLhcoreClassModelESOnlineSession();
$osLog->id = $item->id;
$osLog->user_id = $item->user_id;
$osLog->os_id = $item->id;
$osLog->time = $item->time * 1000;
Expand All @@ -318,7 +319,7 @@ public static function indexOs($params)
$objectsSave[$indexSave][] = $osLog;
}

erLhcoreClassModelESOnlineSession::bulkSave($objectsSave, array('custom_index' => true));
erLhcoreClassModelESOnlineSession::bulkSave($objectsSave, array('custom_index' => true, 'ignore_id' => true));
}

public static function indexChatDelay($params)
Expand Down

0 comments on commit b8b8aa5

Please sign in to comment.