mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-14 03:57:45 +02:00
fix: set cache expiration to next note publish to show note on publication date
fix episode, podcast and persons forms + episode scheduling
This commit is contained in:
parent
fbc0967caa
commit
0a66de3e6c
14 changed files with 117 additions and 44 deletions
|
|
@ -138,13 +138,35 @@ class NoteModel extends UuidModel
|
|||
->orderBy('published_at', 'DESC')
|
||||
->findAll();
|
||||
|
||||
$secondsToNextUnpublishedNote = $this->getSecondsToNextUnpublishedNote($actorId,);
|
||||
|
||||
cache()
|
||||
->save($cacheName, $found, DECADE);
|
||||
->save($cacheName, $found, $secondsToNextUnpublishedNote ? $secondsToNextUnpublishedNote : DECADE,);
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timestamp difference in seconds between the next note to publish and the current timestamp. Returns
|
||||
* false if there's no note to publish
|
||||
*/
|
||||
public function getSecondsToNextUnpublishedNote(int $actorId): int | false
|
||||
{
|
||||
$result = $this->select('TIMESTAMPDIFF(SECOND, NOW(), `published_at`) as timestamp_diff',)
|
||||
->where([
|
||||
'actor_id' => $actorId,
|
||||
])
|
||||
->where('`published_at` > NOW()', null, false)
|
||||
->orderBy('published_at', 'asc')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
return count($result) !== 0
|
||||
? (int) $result[0]['timestamp_diff']
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all published replies for a given note. By default, it does not get replies from blocked actors.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue