aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Entry.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-10-16 21:15:44 +0200
committerGravatar GitHub <noreply@github.com> 2025-10-16 21:15:44 +0200
commitf08f7dcff988de90e899ce310246f0b552a4fe3d (patch)
tree8a96a66aa59e3b1bf675757c5fc555e9187b8625 /app/Models/Entry.php
parentca091fbef4823159060275a293eaa4e65ecaf1c0 (diff)
Sort by article length (#8119)
* Sort by article length fix https://github.com/FreshRSS/Extensions/issues/378 Very basic using simply SQL `LENGTH()` function. <img width="492" height="217" alt="image" src="https://github.com/user-attachments/assets/7cf37303-76c8-4411-b8b1-075e81535b60" /> * Improve content length retrieval
Diffstat (limited to 'app/Models/Entry.php')
-rw-r--r--app/Models/Entry.php15
1 files changed, 14 insertions, 1 deletions
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index 296c3860f..ea124794a 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -28,6 +28,7 @@ class FreshRSS_Entry extends Minz_Model {
/** In microseconds */
private string $date_added = '0';
private string $hash = '';
+ private ?int $sqlContentLength = null;
private ?bool $is_read;
private ?bool $is_favorite;
private bool $is_updated = false;
@@ -56,7 +57,8 @@ class FreshRSS_Entry extends Minz_Model {
/** @param array{id?:string,id_feed?:int,guid?:string,title?:string,author?:string,content?:string,link?:string,
* date?:int|string,lastSeen?:int,lastUserModified?:int,
- * hash?:string,is_read?:bool|int,is_favorite?:bool|int,tags?:string|array<string>,attributes?:?string,thumbnail?:string,timestamp?:string} $dao */
+ * hash?:string,is_read?:bool|int,is_favorite?:bool|int,tags?:string|array<string>,attributes?:?string,thumbnail?:string,timestamp?:string,
+ * content_length?:int} $dao */
public static function fromArray(array $dao): FreshRSS_Entry {
if (empty($dao['content']) || !is_string($dao['content'])) {
$dao['content'] = '';
@@ -108,6 +110,9 @@ class FreshRSS_Entry extends Minz_Model {
if (!empty($dao['hash'])) {
$entry->_hash($dao['hash']);
}
+ if (isset($dao['content_length']) && is_numeric($dao['content_length'])) {
+ $entry->_sqlContentLength((int)$dao['content_length']);
+ }
return $entry;
}
@@ -500,6 +505,10 @@ HTML;
return $this->hash;
}
+ public function sqlContentLength(): ?int {
+ return $this->sqlContentLength;
+ }
+
public function _hash(string $value): string {
$value = trim($value);
if (ctype_xdigit($value)) {
@@ -508,6 +517,10 @@ HTML;
return $this->hash;
}
+ public function _sqlContentLength(int $value): void {
+ $this->sqlContentLength = $value > 0 ? $value : null;
+ }
+
/** @param int|numeric-string $value String is for compatibility with 32-bit platforms */
public function _id(int|string $value): void {
if (is_int($value)) {