Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [pull] Fix pulling from remote server when analyst data is not s… #9605

Merged
merged 1 commit into from Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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