Skip to content

Commit

Permalink
NBNP-448 Implement stats for storage progress
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobSanford committed Jun 26, 2024
1 parent 05df55e commit dbdb985
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,40 @@ public static function getPagesNeedingToMove($limit = 50) {
return $pages;
}

/**
* Gets a count of pages stored in the old location.
*
* @param int $limit
* The number of pages to return. Defaults to 50.
*/
public static function countPagesNeedingToMove() {
$sql = "SELECT COUNT(fid) from file_managed WHERE uri NOT LIKE 'public://serials/pages/%/%/%.jpg' AND uri LIKE 'public://serials/pages/%'";
$result = \Drupal::database()->query($sql);
return $result->fetchCol();
}

/**
* Gets a count of pages stored in the new location.
*
* @param int $limit
* The number of pages to return. Defaults to 50.
*/
public static function countPagesAlreadyMoved() {
$sql = "SELECT COUNT(fid) from file_managed WHERE uri LIKE 'public://serials/pages/%/%/%.jpg'";
$result = \Drupal::database()->query($sql);
return $result->fetchCol();
}

/**
* Print the count of pages needing to move and already moved.
*/
public static function printCountPagesNeedingToMove() {
$count_old = self::countPagesNeedingToMove();
$count_new = self::countPagesAlreadyMoved();
echo "Pages needing to move: $count_old\n";
echo "Pages already moved: $count_new\n";
}

/**
* Move all pages with files stored in the old location to the new location.
*
Expand Down

0 comments on commit dbdb985

Please sign in to comment.