Skip to content

Commit

Permalink
Merge pull request #132 from lilt/4.x-development
Browse files Browse the repository at this point in the history
4.4.0 Release
  • Loading branch information
hadomskyi authored Nov 1, 2023
2 parents e578dc9 + dc83504 commit bcabb9b
Show file tree
Hide file tree
Showing 34 changed files with 960 additions and 133 deletions.
1 change: 1 addition & 0 deletions .github/workflows/craft-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
tests:
strategy:
fail-fast: false
matrix:
craft_version: [
# TODO: check this
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
tests:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
scenario: [
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 4.4.0 - 2023-10-04
### Added
- Queue manager

### Fixed
- Download translations triggered only after all of them are done

## 4.3.0 - 2023-10-04
### Added
- Queue each translation file transfer separately
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "lilt/craft-lilt-plugin",
"description": "The Lilt plugin makes it easy for you to send content to Lilt for translation right from within Craft CMS.",
"type": "craft-plugin",
"version": "4.3.0",
"version": "4.4.0",
"keywords": [
"craft",
"cms",
Expand Down
3 changes: 2 additions & 1 deletion e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ up: clone down composer-install
docker-compose exec -T app sh -c 'echo DB_PASSWORD=craft-lilt >> .env'
docker-compose exec -T app sh -c 'echo DB_SCHEMA=public >> .env'
docker-compose exec -T app sh -c 'echo DB_TABLE_PREFIX= >> .env'
docker-compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_DELAY_IN_SECONDS=5 >> .env'
docker-compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_DELAY_IN_SECONDS=1 >> .env'
docker-compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_MANAGER_WAIT_TIME_IN_SECONDS=86400 >> .env'
docker-compose exec -T app sh -c 'php craft db/restore happylager.sql'
docker-compose exec -T app sh -c 'php craft plugin/install craft-lilt-plugin'
docker-compose exec -T app sh -c 'php craft plugin/install neo'
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "cypress";
export default defineConfig({
viewportWidth: 1920,
viewportHeight: 1080,
defaultCommandTimeout: 60 * 1000,
defaultCommandTimeout: 360 * 1000,
// video: false,
e2e: {
setupNodeEvents(on, config) {
Expand Down
47 changes: 1 addition & 46 deletions e2e/cypress/e2e/jobs/instant/success-path-single.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,4 @@ describe(
languages: ["de"],
})
});

it('with copy slug disabled & enable after publish enabled', () => {
const {jobTitle, slug} = generateJobData();

cy.instantFlow({
slug,
entryLabel,
jobTitle,
entryId,
copySlug: false,
enableAfterPublish: true,
languages: ["de"]
})
});

it('with copy slug enabled & enable after publish disabled', () => {
const {jobTitle, slug} = generateJobData();

cy.instantFlow({
slug,
entryLabel,
jobTitle,
entryId,
copySlug: true,
enableAfterPublish: false,
languages: ["de"]
})
});

it('with copy slug enabled & enable after publish enabled', () => {
const {jobTitle, slug} = generateJobData();

cy.log(`Job title: ${jobTitle}`)
cy.log(`Slug: ${slug}`)

cy.instantFlow({
slug,
entryLabel,
jobTitle,
entryId,
copySlug: true,
enableAfterPublish: true,
languages: ["de"]
})
});
});
});
11 changes: 7 additions & 4 deletions e2e/cypress/support/flow/instant.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Cypress.Commands.add('instantFlow', ({
'updatedAt': '2019-08-24T14:15:22Z',
}),
}, 'times': {
'remainingTimes': 1, 'unlimited': false,
'unlimited': true,
},
}));

Expand Down Expand Up @@ -97,7 +97,7 @@ Cypress.Commands.add('instantFlow', ({
}, 'httpResponse': {
'statusCode': 200, 'body': JSON.stringify(translationResult),
}, 'times': {
'remainingTimes': 1, 'unlimited': false,
'unlimited': true,
},
}));
}
Expand All @@ -120,7 +120,7 @@ Cypress.Commands.add('instantFlow', ({
'limit': 100, 'start': 0, 'results': translationsResult,
}),
}, 'times': {
'remainingTimes': 1, 'unlimited': false,
'unlimited': true,
},
}));

Expand Down Expand Up @@ -214,6 +214,9 @@ Cypress.Commands.add('instantFlow', ({
);

if (isMockserverEnabled) {

cy.log('Setting up mocks for translations download');

for (const language of languages) {
cy.get(
`#translations-list th[data-title="Translation"] div.element[data-target-site-language="${language}"]`).
Expand Down Expand Up @@ -241,7 +244,7 @@ Cypress.Commands.add('instantFlow', ({
'statusCode': 200,
'body': JSON.stringify(translatedContent),
}, 'times': {
'remainingTimes': 1, 'unlimited': false,
'unlimited': true,
},
}));
});
Expand Down
8 changes: 4 additions & 4 deletions e2e/cypress/support/flow/verified.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Cypress.Commands.add('verifiedFlow', ({
'updatedAt': '2019-08-24T14:15:22Z',
}),
}, 'times': {
'remainingTimes': 1, 'unlimited': false,
'unlimited': true,
},
}));

Expand Down Expand Up @@ -97,7 +97,7 @@ Cypress.Commands.add('verifiedFlow', ({
}, 'httpResponse': {
'statusCode': 200, 'body': JSON.stringify(translationResult),
}, 'times': {
'remainingTimes': 1, 'unlimited': false,
'unlimited': true,
},
}));
}
Expand All @@ -120,7 +120,7 @@ Cypress.Commands.add('verifiedFlow', ({
'limit': 100, 'start': 0, 'results': translationsResult,
}),
}, 'times': {
'remainingTimes': 1, 'unlimited': false,
'unlimited': true,
},
}));

Expand Down Expand Up @@ -241,7 +241,7 @@ Cypress.Commands.add('verifiedFlow', ({
'statusCode': 200,
'body': JSON.stringify(translatedContent),
}, 'times': {
'remainingTimes': 1, 'unlimited': false,
'unlimited': true,
},
}));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace craft\contentmigrations;

use Craft;
use craft\base\Field;
use craft\db\Migration;
use craft\fields\Matrix;
use lilthq\craftliltplugin\parameters\CraftliltpluginParameters;
Expand Down
5 changes: 5 additions & 0 deletions src/Craftliltplugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use lilthq\craftliltplugin\services\handlers\RefreshJobStatusHandler;
use lilthq\craftliltplugin\services\handlers\SendJobToLiltConnectorHandler;
use lilthq\craftliltplugin\services\handlers\SendTranslationToLiltConnectorHandler;
use lilthq\craftliltplugin\services\handlers\StartQueueManagerHandler;
use lilthq\craftliltplugin\services\handlers\SyncJobFromLiltConnectorHandler;
use lilthq\craftliltplugin\services\handlers\TranslationFailedHandler;
use lilthq\craftliltplugin\services\handlers\UpdateJobStatusHandler;
Expand Down Expand Up @@ -111,6 +112,7 @@
* @property SettingsRepository $settingsRepository
* @property UpdateTranslationsConnectorIds $updateTranslationsConnectorIds
* @property PackagistRepository $packagistRepository
* @property StartQueueManagerHandler $startQueueManagerHandler
* @property ServiceInitializer $serviceInitializer
*/
class Craftliltplugin extends Plugin
Expand Down Expand Up @@ -239,6 +241,9 @@ public function init(): void
]);
$this->serviceInitializer->run();

// Run queue manager
$this->startQueueManagerHandler->handle();

Craft::info(
Craft::t(
'craft-lilt-plugin',
Expand Down
5 changes: 5 additions & 0 deletions src/elements/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ protected static function defineDefaultTableAttributes(string $source): array
# return "<a href='".UrlHelper::cpUrl('craft-lilt-plugin/job/' . $this->id)."'>$this->title</a>";
#}

public function getFilesCount(): int
{
return count($this->getTargetSiteIds()) * count($this->getElementIds());
}

public function getTargetSiteIds(): array
{
return $this->targetSiteIds;
Expand Down
11 changes: 9 additions & 2 deletions src/modules/AbstractRetryJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use craft\queue\BaseJob;
use lilthq\craftliltplugin\elements\Job;
use lilthq\craftliltplugin\records\JobRecord;
use RuntimeException;

abstract class AbstractRetryJob extends BaseJob
{
Expand Down Expand Up @@ -40,8 +41,14 @@ abstract public function getRetryJob(): BaseJob;

protected function getCommand(): ?Command
{
if (!Craft::$app->getMutex()->acquire($this->getMutexKey())) {
Craft::error(sprintf('Job %s is already processing job %d', __CLASS__, $this->jobId));
if (
!Craft::$app->getMutex()->acquire(
$this->getMutexKey()
)
) {
$msg = sprintf('Job %s is already processing %s', __CLASS__, $this->getMutexKey());

Craft::error($msg);

return null;
}
Expand Down
Loading

0 comments on commit bcabb9b

Please sign in to comment.