Commit 853a6ba9 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix: use UTC_TIMESTAMP() to get current utc date instead of NOW() in sql queries

parent e9d4b4ae
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ class EpisodeController extends BaseController
                    ->from(config('Fediverse')->tablesPrefix . 'posts')
                    ->where('episode_id', $this->episode->id);
            })
            ->where('`published_at` <= NOW()', null, false)
            ->where('`published_at` <= UTC_TIMESTAMP()', null, false)
            ->orderBy('published_at', 'ASC');

        $pageNumber = (int) $this->request->getGet('page');
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ class MapController extends BaseController
        $cacheName = 'episodes_markers';
        if (! ($found = cache($cacheName))) {
            $episodes = (new EpisodeModel())
                ->where('`published_at` <= NOW()', null, false)
                ->where('`published_at` <= UTC_TIMESTAMP()', null, false)
                ->where('location_geo is not', null)
                ->findAll();
            $found = [];
+2 −2
Original line number Diff line number Diff line
@@ -287,11 +287,11 @@ class PodcastController extends BaseController
        if ($this->podcast->type === 'serial') {
            // podcast is serial
            $episodes = model(EpisodeModel::class)
                ->where('`published_at` <= NOW()', null, false)
                ->where('`published_at` <= UTC_TIMESTAMP()', null, false)
                ->orderBy('season_number DESC, number ASC');
        } else {
            $episodes = model(EpisodeModel::class)
                ->where('`published_at` <= NOW()', null, false)
                ->where('`published_at` <= UTC_TIMESTAMP()', null, false)
                ->orderBy('published_at', 'DESC');
        }

+4 −2
Original line number Diff line number Diff line
@@ -41,8 +41,10 @@ class AddPlatforms extends Migration
                'null' => true,
            ],
        ]);
        $this->forge->addField('`created_at` timestamp NOT NULL DEFAULT NOW()');
        $this->forge->addField('`updated_at` timestamp NOT NULL DEFAULT NOW() ON UPDATE NOW()');
        $this->forge->addField('`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP()');
        $this->forge->addField(
            '`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP()'
        );
        $this->forge->addPrimaryKey('slug');
        $this->forge->createTable('platforms');
    }
+2 −4
Original line number Diff line number Diff line
@@ -3,8 +3,6 @@
declare(strict_types=1);

/**
 * Class AddCreditView Creates Credit View in database
 *
 * @copyright  2020 Ad Aures
 * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
 * @link       https://castopod.org/
@@ -14,7 +12,7 @@ namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddCreditView extends Migration
class AddCreditsView extends Migration
{
    public function up(): void
    {
@@ -35,7 +33,7 @@ class AddCreditView extends Migration
                    ON (`person_id`=`{$personsTable}`.`id`)
                INNER JOIN `{$episodesTable}`
                    ON (`episode_id`=`{$episodesTable}`.`id`)
            WHERE `{$episodesTable}`.published_at <= NOW()
            WHERE `{$episodesTable}`.published_at <= UTC_TIMESTAMP()
            ORDER BY `person_group`, `full_name`, `person_role`, `podcast_id`, `episode_id`;
        CODE_SAMPLE;
        $this->db->query($createQuery);
Loading