Skip to content

Commit

Permalink
Improve auto-propagation and management of the dashes (#3693)
Browse files Browse the repository at this point in the history
* Improved dash and links management

* Optimized performances

* Chore

* Updated submodule

* Fixed Bulk Status Change Worker

* Improved Bulk segment status change

* Disabled new regexp for urls

* Disabled test because a strange behaviour of regexp in the test
container

* Removed test on links

* Improved Hyphen detection

* Improved Hyphen detection
  • Loading branch information
Ostico authored Dec 16, 2024
1 parent be262cb commit 7bd745a
Show file tree
Hide file tree
Showing 22 changed files with 616 additions and 453 deletions.
2 changes: 1 addition & 1 deletion docker
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function _validate() {
"/^10\.3\.15\..*/",
"/^10\.6\..*/",
"/^10\.128\..*/",
"/^10\.144\..*/",
"/^172\.(?:1[6-9]|2[0-9]|3[0-1])\..*/",
"/^149\.7\.212\..*/",
"/^127\.0\.0\..*/",
Expand Down
3 changes: 1 addition & 2 deletions lib/Controller/getSearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,8 @@ private function _updateSegments( $search_results ): void {
$propagationTotal = Translations_SegmentTranslationDao::propagateTranslation(
$TPropagation,
$this->job_data,
$this->id_segment,
(int)$this->id_segment,
$project,
$versionsHandler
);

} catch ( Exception $e ) {
Expand Down
3 changes: 1 addition & 2 deletions lib/Controller/setTranslationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,8 @@ public function doAction() {
$propagationTotal = Translations_SegmentTranslationDao::propagateTranslation(
$TPropagation,
$this->chunk,
$this->id_segment,
(int)$this->id_segment,
$this->project,
$this->VersionsHandler
);
}

Expand Down
1 change: 1 addition & 0 deletions lib/Model/DataAccess/AbstractDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ protected function _fetchObject( PDOStatement $stmt, DataAccess_IDaoStruct $fetc
$stmt->setFetchMode( PDO::FETCH_CLASS, get_class( $fetchClass ) );
$stmt->execute( $bindParams );
$result = $stmt->fetchAll();
$stmt->closeCursor();

$this->_setInCache( $stmt->queryString . $this->_serializeForCacheKey( $bindParams ) . get_class( $fetchClass ), $result );

Expand Down
79 changes: 49 additions & 30 deletions lib/Model/Propagation/PropagationTotalStruct.php
Original file line number Diff line number Diff line change
@@ -1,54 +1,47 @@
<?php

class Propagation_PropagationTotalStruct extends DataAccess_AbstractDaoObjectStruct implements DataAccess_IDaoStruct {
class Propagation_PropagationTotalStruct extends DataAccess_AbstractDaoSilentStruct implements DataAccess_IDaoStruct, JsonSerializable {

/**
* @var array
*/
private $totals;
protected array $totals = [];

/**
* @var array
*/
private $propagated_ids;
protected array $propagated_ids = [];

/**
* @var array
*/
private $propagated_ids_to_update_version;
protected array $propagated_ids_to_update_version = [];

/**
* @var array
*/
private $segments_for_propagation;

public function __construct() {
$this->totals = [];
$this->propagated_ids = [];
$this->propagated_ids_to_update_version = [];
$this->segments_for_propagation = [
'propagated' => [
'ice' => [],
'not_ice' => [],
],
'not_propagated' => [
'ice' => [],
'not_ice' => [],
],
];
}
protected array $segments_for_propagation = [
'propagated' => [
'ice' => [],
'not_ice' => [],
],
'not_propagated' => [
'ice' => [],
'not_ice' => [],
],
];

/**
* @return array
*/
public function getTotals() {
public function getTotals(): array {
return $this->totals;
}

/**
* @param array $params
*/
public function setTotals( $params ) {
public function setTotals( array $params ) {
$this->totals[ 'total' ] = $params[ 'total' ];
$this->totals[ 'countSeg' ] = $params[ 'countSeg' ];
$this->totals[ 'status' ] = $params[ 'status' ];
Expand All @@ -57,14 +50,14 @@ public function setTotals( $params ) {
/**
* @return array
*/
public function getPropagatedIds() {
public function getPropagatedIds(): array {
return $this->propagated_ids;
}

/**
* @param int $id_segment
*/
public function addPropagatedId( $id_segment ) {
public function addPropagatedId( int $id_segment ) {
if ( false === in_array( $id_segment, $this->propagated_ids ) ) {
$this->propagated_ids[] = $id_segment;
$this->segments_for_propagation[ 'propagated_ids' ][] = $id_segment;
Expand All @@ -74,23 +67,23 @@ public function addPropagatedId( $id_segment ) {
/**
* @return array
*/
public function getPropagatedIdsToUpdateVersion() {
public function getPropagatedIdsToUpdateVersion(): array {
return $this->propagated_ids_to_update_version;
}

/**
* @param int $id_segment
*/
public function addPropagatedIdToUpdateVersion( $id_segment ) {
public function addPropagatedIdToUpdateVersion( int $id_segment ) {
if ( false === in_array( $id_segment, $this->propagated_ids_to_update_version ) ) {
$this->propagated_ids_to_update_version[] = $id_segment;
$this->propagated_ids_to_update_version[ $id_segment ] = $id_segment;
}
}

/**
* @return array
*/
public function getSegmentsForPropagation() {
public function getSegmentsForPropagation(): array {
return $this->segments_for_propagation;
}

Expand Down Expand Up @@ -127,6 +120,32 @@ public function addNotPropagatedNotIce( Translations_SegmentTranslationStruct $s
$this->segments_for_propagation[ 'not_propagated' ][ 'not_ice' ][ 'id' ][] = $segmentTranslation->id_segment;
$this->segments_for_propagation[ 'not_propagated' ][ 'not_ice' ][ 'object' ][] = $segmentTranslation;
}
}

public function jsonSerialize(): array {
return [
"totals" => $this->totals,
"propagated_ids" => $this->propagated_ids,
"propagated_ids_to_update_version" => $this->propagated_ids_to_update_version,
"segments_for_propagation" => $this->segments_for_propagation,
];
}

public function getAllToPropagate(): array {
$aggregator = [];

if ( !empty( $this->segments_for_propagation[ 'propagated' ][ 'ice' ][ 'object' ] ) ) {
foreach ( $this->segments_for_propagation[ 'propagated' ][ 'ice' ][ 'object' ] as $segment ) {
$aggregator[] = $segment;
}
}

if ( !empty( $this->segments_for_propagation[ 'propagated' ][ 'not_ice' ][ 'object' ] ) ) {
foreach ( $this->segments_for_propagation[ 'propagated' ][ 'not_ice' ][ 'object' ] as $segment ) {
$aggregator[] = $segment;
}
}

return $aggregator;
}

}
Loading

0 comments on commit 7bd745a

Please sign in to comment.