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

feat: Change to be able to sync test #473

Merged
merged 13 commits into from
May 14, 2024
Merged

Conversation

yaraslau-kavaliou
Copy link
Contributor

@yaraslau-kavaliou yaraslau-kavaliou commented Mar 18, 2024

Copy link

github-actions bot commented Mar 18, 2024

Front-end summary Node 18

💯 Total ✅ Passed ⏭️ Skipped ❌ Failed
13 13 0 0

@codecov-commenter
Copy link

codecov-commenter commented Mar 18, 2024

Codecov Report

Attention: Patch coverage is 37.50000% with 45 lines in your changes are missing coverage. Please review.

Project coverage is 16.21%. Comparing base (e5bf1b6) to head (6a06ac0).

Files Patch % Lines
model/DataStore/PersistDataService.php 15.62% 27 Missing ⚠️
model/DataStore/DeliveryMetadataListener.php 52.38% 10 Missing ⚠️
model/DataStore/MetaDataDeliverySyncTask.php 57.89% 8 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #473      +/-   ##
=============================================
+ Coverage      15.98%   16.21%   +0.23%     
- Complexity       749      756       +7     
=============================================
  Files             75       75              
  Lines           2659     2701      +42     
=============================================
+ Hits             425      438      +13     
- Misses          2234     2263      +29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -38,7 +38,7 @@ class DeliveryMetadataListener extends ConfigurableService

public const SERVICE_ID = 'taoDeliveryRdf/DeliveryMetadataListener';

public const OPTION_MAX_TRIES = 'max_tries';
public const FILE_SYSTEM_ID = 'dataStore';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Is it required to have this constant public if it is only used here in this class?

Copy link
Contributor Author

@yaraslau-kavaliou yaraslau-kavaliou May 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

MetaDataDeliverySyncTask::INCLUDE_METADATA_PARAM_NAME => true,
MetaDataDeliverySyncTask::MAX_TRIES_PARAM_NAME => $this->getOption('max_tries', 10),
MetaDataDeliverySyncTask::FILE_SYSTEM_ID_PARAM_NAME => self::FILE_SYSTEM_ID,
MetaDataDeliverySyncTask::IS_REMOVE_PARAM_NAME => false,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: As I understood this param is responsible for marking tests as deleted in the data storage, so would it be better to call isDelete? This way its intent would be much more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

$report = new Report(Report::TYPE_SUCCESS);

if ($params['count'] < $params[DeliveryMetadataListener::OPTION_MAX_TRIES]) {
$params['count'] = $params['count'] ?? 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: seems like we have constants for all params except count do you think we should introduce one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -44,30 +44,48 @@ class MetaDataDeliverySyncTask extends AbstractAction implements JsonSerializabl
{
use OntologyAwareTrait;

public const INCLUDE_DELIVERY_METADATA_PARAM_NAME = 'includeMetadata';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore: does it make sense to rename the class to match it's new purpose as it is now processing not only deliveries but also tests, what do you think?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion better would be to have separate classes and reuse common logic. What if we would introduce couple of more entities? How that would look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate task has been created for test processing

if (!isset($params['deliveryMetaData'], $params['testMetaData'], $params['testUri'], $params['itemMetaData'])) {
$compiler = $this->getMetaDataCompiler();
$compiler = $this->getMetaDataCompiler();
if ($params[self::INCLUDE_DELIVERY_METADATA_PARAM_NAME]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it is surprising that same parameter can have both delivery or test id, and that test will be treated as delivery. I think this way it could be confusing, better not mix it up. If it is a test triggering this task, then it is compiled 2 times?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this is a design smell to me too. It looks like it would be better to have separate events/params.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

model/DataStore/MetaDataDeliverySyncTask.php Outdated Show resolved Hide resolved
model/DataStore/DeliveryMetadataListener.php Outdated Show resolved Hide resolved
Copy link
Collaborator

@augustas augustas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be more explicit that its test package being compiled and uploaded

@@ -99,25 +125,28 @@ private function persistArchive(string $deliveryId, array $params): void
* @throws common_exception_Error
* @throws common_exception_NotFound
*/
private function moveExportedZipTest(string $folder, string $deliveryId, array $params): void
private function moveExportedZipTest(string $folder, string $deliveryOrTestId, array $params): void
Copy link

@progys progys Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: I would rename deliveryOrTestId to entityId in this context it does not look to be important to know that it can hold testId or deliveryId.

P.S. seems to be the case in majority of methods, so please check everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced to resourceId in this case

@yaraslau-kavaliou yaraslau-kavaliou force-pushed the feat/REL-1538/test-ds-sync branch 3 times, most recently from f5c3201 to 0a7abf7 Compare May 6, 2024 18:44

private function getResourceJsonMetadataCompiler(): ResourceMetadataCompilerInterface
{
return $this->getServiceManager()->getContainer()->get(ResourceJsonMetadataCompiler::SERVICE_ID);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably could do $this->getServiceLocator()->get(ResourceJsonMetadataCompiler::SERVICE_ID);

$testUri = $this->getTestUri($deliveryResource);
}

$test = $this->getResource($resourceId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method still is a bit confusing to me, since both delivery or test can arrive here as $resourceId. In order for test metadata to be correct in case $resourceId comes from delivery I believe this should be updated:

Suggested change
$test = $this->getResource($resourceId);
$test = $this->getResource($testUri);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks for the great catch!

Copy link

github-actions bot commented May 8, 2024

Version

Target Version 14.21.0
Last version 14.20.2

There are 0 BREAKING CHANGE, 7 features, 3 fixes

@augustas augustas merged commit 54708e5 into develop May 14, 2024
5 of 6 checks passed
@augustas augustas deleted the feat/REL-1538/test-ds-sync branch May 14, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants