Skip to content

Commit

Permalink
Merge pull request #9605 from JakubOnderka/fix-pull-analyst
Browse files Browse the repository at this point in the history
fix: [pull] Fix pulling from remote server when analyst data is not s…
  • Loading branch information
JakubOnderka committed Mar 5, 2024
2 parents 6a2986b + 5acf0a9 commit e79fc41
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
17 changes: 9 additions & 8 deletions app/Lib/Tools/ServerSyncTool.php
Expand Up @@ -217,15 +217,15 @@ public function pushGalaxyCluster(array $cluster)
}

/**
* @param array $rules
* @param array $candidates
* @return HttpSocketResponseExtended
* @throws HttpSocketHttpException
* @throws HttpSocketJsonException
*/
public function filterAnalystDataForPush(array $candidates)
{
if (!$this->isSupported(self::PERM_ANALYST_DATA)) {
return [];
throw new RuntimeException("Remote server do not support analyst data");
}

return $this->post('/analyst_data/filterAnalystDataForPush', $candidates);
Expand All @@ -240,20 +240,23 @@ public function filterAnalystDataForPush(array $candidates)
public function fetchIndexMinimal(array $rules)
{
if (!$this->isSupported(self::PERM_ANALYST_DATA)) {
return [];
throw new RuntimeException("Remote server do not support analyst data");
}

return $this->post('/analyst_data/indexMinimal', $rules);
}

/**
* @param string $type
* @param array $uuids
* @return HttpSocketResponseExtended
* @throws HttpSocketJsonException
* @throws HttpSocketHttpException
*/
public function fetchAnalystData($type, array $uuids)
{
if (!$this->isSupported(self::PERM_ANALYST_DATA)) {
return [];
throw new RuntimeException("Remote server do not support analyst data");
}

$params = [
Expand All @@ -264,12 +267,10 @@ public function fetchAnalystData($type, array $uuids)
$url .= $this->createParams($params);
$url .= '.json';
return $this->get($url);

// $response = $this->post('/analyst_data/restSearch' , $params);
// return $response->json();
}

/**
/**
* @param string $type
* @param array $analystData
* @return HttpSocketResponseExtended
* @throws HttpSocketHttpException
Expand Down
12 changes: 7 additions & 5 deletions app/Model/AnalystData.php
Expand Up @@ -1007,9 +1007,14 @@ private function updateAnalystDataForSync($type, array $analystData, array $serv
*
* @param array $user
* @param ServerSyncTool $serverSync
* @return int Number of saved analysis
*/
public function pull(array $user, ServerSyncTool $serverSync)
{
if (!$serverSync->isSupported(ServerSyncTool::PERM_ANALYST_DATA)) {
return 0;
}

$this->Server = ClassRegistry::init('Server');
$this->AnalystData = ClassRegistry::init('AnalystData');
try {
Expand Down Expand Up @@ -1051,14 +1056,11 @@ public function pull(array $user, ServerSyncTool $serverSync)
return 0;
}

if ($serverSync->isSupported(ServerSyncTool::PERM_ANALYST_DATA)) {
return $this->pullInChunks($user, $remoteUUIDsToFetch, $serverSync);
}
return $this->pullInChunks($user, $remoteUUIDsToFetch, $serverSync);
}

public function pullInChunks(array $user, array $analystDataUuids, ServerSyncTool $serverSync)
private function pullInChunks(array $user, array $analystDataUuids, ServerSyncTool $serverSync)
{
$uuids = array_keys($analystDataUuids);
$saved = 0;
$serverOrgUUID = $this->Org->find('first', [
'recursive' => -1,
Expand Down

0 comments on commit e79fc41

Please sign in to comment.