summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2021-02-04 21:45:21 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-02-05 09:37:17 +0100
commit6e9e2512eaa94c753119e22b6224de267d9fd968 (patch)
treeda7e068c509153bef4147cc2d08765cd15fbb085 /lib
parent76298c011b6a22baf213221345e1f87ae0ec3cd7 (diff)
DB: Remove unused fields
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib')
-rw-r--r--lib/Db/Feed.php24
-rw-r--r--lib/Db/Item.php38
-rw-r--r--lib/Migration/Version150203Date20210204203051.php76
-rw-r--r--lib/Service/FeedServiceV2.php1
4 files changed, 86 insertions, 53 deletions
diff --git a/lib/Db/Feed.php b/lib/Db/Feed.php
index 1d5721d3b..c468f8272 100644
--- a/lib/Db/Feed.php
+++ b/lib/Db/Feed.php
@@ -64,8 +64,6 @@ class Feed extends Entity implements IAPI, \JsonSerializable
/** @var string|null */
protected $lastModified = '0';
/** @var string|null */
- protected $httpEtag = null;
- /** @var string|null */
protected $location = null;
/** @var int */
protected $ordering = 0;
@@ -101,7 +99,6 @@ class Feed extends Entity implements IAPI, \JsonSerializable
$this->addType('articlesPerUpdate', 'integer');
$this->addType('httpLastModified', 'string');
$this->addType('lastModified', 'string');
- $this->addType('httpEtag', 'string');
$this->addType('location', 'string');
$this->addType('ordering', 'integer');
$this->addType('fullTextEnabled', 'boolean');
@@ -180,14 +177,6 @@ class Feed extends Entity implements IAPI, \JsonSerializable
/**
* @return string|null
*/
- public function getHttpEtag(): ?string
- {
- return $this->httpEtag;
- }
-
- /**
- * @return string|null
- */
public function getHttpLastModified(): ?string
{
return $this->httpLastModified;
@@ -454,19 +443,6 @@ class Feed extends Entity implements IAPI, \JsonSerializable
}
/**
- * @param string|null $httpEtag
- */
- public function setHttpEtag(?string $httpEtag = null): Feed
- {
- if ($this->httpEtag !== $httpEtag) {
- $this->httpEtag = $httpEtag;
- $this->markFieldUpdated('httpEtag');
- }
-
- return $this;
- }
-
- /**
* @param string|null $httpLastModified
*/
public function setHttpLastModified(?string $httpLastModified = null): Feed
diff --git a/lib/Db/Item.php b/lib/Db/Item.php
index cb10900d4..abfcf6506 100644
--- a/lib/Db/Item.php
+++ b/lib/Db/Item.php
@@ -39,8 +39,6 @@ class Item extends Entity implements IAPI, \JsonSerializable
protected $author;
/** @var int|null */
protected $pubDate;
- /** @var int|null */
- protected $updatedDate;
/** @var string|null */
protected $body;
/** @var string|null */
@@ -53,8 +51,6 @@ class Item extends Entity implements IAPI, \JsonSerializable
protected $mediaDescription;
/** @var int */
protected $feedId;
- /** @var int */
- protected $status = 0;
/** @var string|null */
protected $lastModified = '0';
/** @var string|null */
@@ -77,14 +73,12 @@ class Item extends Entity implements IAPI, \JsonSerializable
$this->addType('title', 'string');
$this->addType('author', 'string');
$this->addType('pubDate', 'integer');
- $this->addType('updatedDate', 'integer');
$this->addType('body', 'string');
$this->addType('enclosureMime', 'string');
$this->addType('enclosureLink', 'string');
$this->addType('mediaThumbnail', 'string');
$this->addType('mediaDescription', 'string');
$this->addType('feedId', 'integer');
- $this->addType('status', 'integer');
$this->addType('lastModified', 'string');
$this->addType('searchIndex', 'string');
$this->addType('rtl', 'boolean');
@@ -115,7 +109,6 @@ class Item extends Entity implements IAPI, \JsonSerializable
$item->setTitle($import['title']);
$item->setAuthor($import['author']);
$item->setPubDate($import['pubDate']);
- $item->setUpdatedDate($import['updatedDate']);
$item->setBody($import['body']);
$item->setEnclosureMime($import['enclosureMime']);
$item->setEnclosureLink($import['enclosureLink']);
@@ -265,14 +258,6 @@ class Item extends Entity implements IAPI, \JsonSerializable
}
/**
- * @return int|null
- */
- public function getUpdatedDate(): ?int
- {
- return $this->updatedDate;
- }
-
- /**
* @return null|string
*/
public function getUrl(): ?string
@@ -303,7 +288,7 @@ class Item extends Entity implements IAPI, \JsonSerializable
'title' => $this->getTitle(),
'author' => $this->getAuthor(),
'pubDate' => $this->getPubDate(),
- 'updatedDate' => $this->getUpdatedDate(),
+ 'updatedDate' => null,
'body' => $this->getBody(),
'enclosureMime' => $this->getEnclosureMime(),
'enclosureLink' => $this->getEnclosureLink(),
@@ -507,16 +492,6 @@ class Item extends Entity implements IAPI, \JsonSerializable
return $this;
}
- public function setUpdatedDate(int $updatedDate = null): self
- {
- if ($this->updatedDate !== $updatedDate) {
- $this->updatedDate = $updatedDate;
- $this->markFieldUpdated('updatedDate');
- }
-
- return $this;
- }
-
public function setUrl(string $url = null): self
{
$url = trim($url);
@@ -540,7 +515,7 @@ class Item extends Entity implements IAPI, \JsonSerializable
'title' => $this->getTitle(),
'author' => $this->getAuthor(),
'pubDate' => $this->getPubDate(),
- 'updatedDate' => $this->getUpdatedDate(),
+ 'updatedDate' => null,
'body' => $this->getBody(),
'enclosureMime' => $this->getEnclosureMime(),
'enclosureLink' => $this->getEnclosureLink(),
@@ -556,6 +531,13 @@ class Item extends Entity implements IAPI, \JsonSerializable
];
}
+ /**
+ * Format for exporting.
+ *
+ * @param $feeds
+ *
+ * @return array
+ */
public function toExport($feeds): array
{
return [
@@ -564,7 +546,7 @@ class Item extends Entity implements IAPI, \JsonSerializable
'title' => $this->getTitle(),
'author' => $this->getAuthor(),
'pubDate' => $this->getPubDate(),
- 'updatedDate' => $this->getUpdatedDate(),
+ 'updatedDate' => null,
'body' => $this->getBody(),
'enclosureMime' => $this->getEnclosureMime(),
'enclosureLink' => $this->getEnclosureLink(),
diff --git a/lib/Migration/Version150203Date20210204203051.php b/lib/Migration/Version150203Date20210204203051.php
new file mode 100644
index 000000000..840ae9849
--- /dev/null
+++ b/lib/Migration/Version150203Date20210204203051.php
@@ -0,0 +1,76 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OCA\News\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+use function PHPUnit\Framework\returnValue;
+
+/**
+ * Auto-generated migration step: Please modify to your needs!
+ */
+class Version150203Date20210204203051 extends SimpleMigrationStep {
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ */
+ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if ($schema->hasTable('news_items') &&
+ $schema->getTable('news_items')->hasColumn('last_modified') &&
+ $schema->getTable('news_items')->getColumn('last_modified')->getUnsigned()
+ ) {
+ $schema->getTable('news_items')
+ ->getColumn('last_modified')
+ ->setUnsigned(false);
+ }
+
+ if ($schema->hasTable('news_items') &&
+ $schema->getTable('news_items')->hasColumn('updated_date')
+ ) {
+ $schema->getTable('news_items')
+ ->dropColumn('updated_date');
+ }
+
+ if ($schema->hasTable('news_items') &&
+ $schema->getTable('news_items')->hasColumn('status')
+ ) {
+ $schema->getTable('news_items')
+ ->dropColumn('status');
+ }
+
+ if ($schema->hasTable('news_feeds') &&
+ $schema->getTable('news_feeds')->hasColumn('http_etag')
+ ) {
+ $schema->getTable('news_feeds')
+ ->dropColumn('http_etag');
+ }
+
+ return $schema;
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ */
+ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
+ }
+}
diff --git a/lib/Service/FeedServiceV2.php b/lib/Service/FeedServiceV2.php
index b4e1dfa88..078941752 100644
--- a/lib/Service/FeedServiceV2.php
+++ b/lib/Service/FeedServiceV2.php
@@ -288,7 +288,6 @@ class FeedServiceV2 extends Service
}
$feed->setHttpLastModified($fetchedFeed->getHttpLastModified())
- ->setHttpEtag($fetchedFeed->getHttpEtag())
->setLocation($fetchedFeed->getLocation());
foreach (array_reverse($items) as &$item) {