Skip to content

Commit b8b8aa5

Browse files
committed
User primary key as index for online sessions
1 parent fc9b415 commit b8b8aa5

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

classes/erlhcoreclassmodelesonlinesession.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,15 @@ public function __get($var)
2424
case 'time_front':
2525
$this->time_front = date('Ymd') == date('Ymd', $this->time / 1000) ? date(erLhcoreClassModule::$dateHourFormat, $this->time / 1000) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time / 1000);
2626
return $this->time_front;
27-
;
28-
break;
29-
27+
3028
case 'lactivity_front':
3129
$this->lactivity_front = date('Ymd') == date('Ymd', $this->lactivity / 1000) ? date(erLhcoreClassModule::$dateHourFormat, $this->lactivity / 1000) : date(erLhcoreClassModule::$dateDateHourFormat, $this->lactivity / 1000);
3230
return $this->lactivity_front;
33-
;
34-
break;
35-
31+
3632
case 'duration_front':
3733
$this->duration_front = erLhcoreClassChat::formatSeconds($this->duration);
3834
return $this->duration_front;
39-
;
40-
break;
41-
35+
4236
default:
4337
break;
4438
}

classes/lhelasticsearchindex.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public static function indexOs($params)
272272
}
273273

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

@@ -293,6 +293,7 @@ public static function indexOs($params)
293293
$osLog = $documentsReindexed[$keyValue];
294294
} else {
295295
$osLog = new erLhcoreClassModelESOnlineSession();
296+
$osLog->id = $item->id;
296297
$osLog->user_id = $item->user_id;
297298
$osLog->os_id = $item->id;
298299
$osLog->time = $item->time * 1000;
@@ -318,7 +319,7 @@ public static function indexOs($params)
318319
$objectsSave[$indexSave][] = $osLog;
319320
}
320321

321-
erLhcoreClassModelESOnlineSession::bulkSave($objectsSave, array('custom_index' => true));
322+
erLhcoreClassModelESOnlineSession::bulkSave($objectsSave, array('custom_index' => true, 'ignore_id' => true));
322323
}
323324

324325
public static function indexChatDelay($params)

0 commit comments

Comments
 (0)