Skip to content

Commit

Permalink
Merge pull request #29 from saadbruno/no-update-on-existing
Browse files Browse the repository at this point in the history
avoid changing the "submitted at" value when plugin already exists
  • Loading branch information
saadbruno authored Sep 12, 2022
2 parents 689cbdc + 172874d commit e91195f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
4 changes: 2 additions & 2 deletions code/bin/update_plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
if ($argv[1]) { // if the user provided a specific github URL to update

$githubUrl = $argv[1];
savePlugin($githubUrl, true);
savePlugin($githubUrl);

} else { // else we run for all plugins

Expand All @@ -33,6 +33,6 @@
$plugins_array = $stmt_plugins->fetchAll();

foreach ($plugins_array as $row_plugins) {
savePlugin($row_plugins['url'], true);
savePlugin($row_plugins['url']);
}
}
22 changes: 4 additions & 18 deletions code/lib/db/submit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

function savePlugin($githubUrl, $skipDate = false)
function savePlugin($githubUrl)
{
// all the logic for submitting new plugins

Expand Down Expand Up @@ -159,22 +159,13 @@ function savePlugin($githubUrl, $skipDate = false)

// PLUGINS db insert
$sql = "INSERT INTO `plugins` (`id`, `name`, `url`, `description`, ";
if($skipDate == false) {
$sql .= "`submittedAt`, ";
}
$sql .= "`submittedAt`, ";
$sql .= "`updatedAt`, `usesCustomOpenGraphImage`, `thumbnail`, `stargazers`, `owner`, `readme`, `licenseName`, `licenseUrl`) ";
$sql .= "VALUES (?,?,?,?,";
if($skipDate == false) {
$sql .= "?,";
}
$sql .= "?,?,?,?,?,?,?,?) ";
$sql .= "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
$sql .= "ON DUPLICATE KEY UPDATE ";
$sql .= "`name` = ?, ";
$sql .= "`url` = ?, ";
$sql .= "`description` = ?, ";
if($skipDate == false) {
$sql .= "`submittedAt` = ?, ";
}
$sql .= "`updatedAt` = ?, ";
$sql .= "`usesCustomOpenGraphImage` = ?, ";
$sql .= "`thumbnail` = ?, ";
Expand All @@ -192,9 +183,7 @@ function savePlugin($githubUrl, $skipDate = false)
array_push($args, $result['data']['repository']['name']);
array_push($args, $result['data']['repository']['url']);
array_push($args, $result['data']['repository']['description']);
if($skipDate == false) {
array_push($args, $submittedAt);
}
array_push($args, $submittedAt);
array_push($args, $updatedAt);
array_push($args, $usesOGImg);
array_push($args, $result['data']['repository']['openGraphImageUrl']);
Expand All @@ -206,9 +195,6 @@ function savePlugin($githubUrl, $skipDate = false)
array_push($args, $result['data']['repository']['name']);
array_push($args, $result['data']['repository']['url']);
array_push($args, $result['data']['repository']['description']);
if($skipDate == false) {
array_push($args, $submittedAt);
}
array_push($args, $updatedAt);
array_push($args, $usesOGImg);
array_push($args, $result['data']['repository']['openGraphImageUrl']);
Expand Down

0 comments on commit e91195f

Please sign in to comment.