DB: Remove unused fields

Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
This commit is contained in:
Sean Molenaar 2021-02-04 21:45:21 +01:00 committed by Sean Molenaar
parent 76298c011b
commit 6e9e2512ea
11 changed files with 169 additions and 76 deletions

View File

@ -5,6 +5,7 @@ The format is almost based on [Keep a Changelog](https://keepachangelog.com/en/1
## [Unreleased]
### Changed
- DB: Remove unused fields
### Fixed
- Release: create signature file (#1117)

View File

@ -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');
@ -177,14 +174,6 @@ class Feed extends Entity implements IAPI, \JsonSerializable
return $this->fullTextEnabled;
}
/**
* @return string|null
*/
public function getHttpEtag(): ?string
{
return $this->httpEtag;
}
/**
* @return string|null
*/
@ -453,19 +442,6 @@ class Feed extends Entity implements IAPI, \JsonSerializable
return $this;
}
/**
* @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
*/

View File

@ -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']);
@ -264,14 +257,6 @@ class Item extends Entity implements IAPI, \JsonSerializable
return $this->title;
}
/**
* @return int|null
*/
public function getUpdatedDate(): ?int
{
return $this->updatedDate;
}
/**
* @return null|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(),

View File

@ -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 {
}
}

View File

@ -288,7 +288,6 @@ class FeedServiceV2 extends Service
}
$feed->setHttpLastModified($fetchedFeed->getHttpLastModified())
->setHttpEtag($fetchedFeed->getHttpEtag())
->setLocation($fetchedFeed->getLocation());
foreach (array_reverse($items) as &$item) {

View File

@ -25,7 +25,6 @@ class FeedTest extends TestCase
$feed = new Feed();
$feed->setId(3);
$feed->setHttpLastModified(44);
$feed->setHttpEtag(45);
$feed->setUrl('http://google.com/some/weird/path');
$feed->setTitle('title');
$feed->setFaviconLink('favicon');
@ -129,4 +128,54 @@ class FeedTest extends TestCase
}
public function testSetAdded()
{
$feed = new Feed();
$feed->setAdded(15);
$this->assertEquals(15, $feed->getAdded());
}
public function testSetDeletedAt()
{
$feed = new Feed();
$feed->setDeletedAt(15);
$this->assertEquals(15, $feed->getDeletedAt());
}
public function testSetFaviconLink()
{
$feed = new Feed();
$feed->setFaviconLink('https://url');
$this->assertEquals('https://url', $feed->getFaviconLink());
}
public function testSetLastModified()
{
$feed = new Feed();
$feed->setLastModified('15');
$this->assertEquals('15', $feed->getLastModified());
}
public function testSetLastUpdateError()
{
$feed = new Feed();
$feed->setLastUpdateError('NO');
$this->assertEquals('NO', $feed->getLastUpdateError());
}
public function testSetUpdateErrorCount()
{
$feed = new Feed();
$feed->setUpdateErrorCount('5');
$this->assertEquals('5', $feed->getUpdateErrorCount());
}
public function testSetOrdering()
{
$feed = new Feed();
$feed->setOrdering(1);
$this->assertEquals(1, $feed->getOrdering());
}
public function testSetPinned()
{
$feed = new Feed();
$feed->setPinned(true);
$this->assertEquals(true, $feed->getPinned());
}
}

View File

@ -59,4 +59,28 @@ class FolderTest extends TestCase
], $folder->jsonSerialize()
);
}
public function testSetDeletedAt()
{
$folder = new Folder();
$folder->setDeletedAt(15);
$this->assertEquals(15, $folder->getDeletedAt());
}
public function testSetLastModified()
{
$folder = new Folder();
$folder->setLastModified('15');
$this->assertEquals('15', $folder->getLastModified());
}
public function testSetParentId()
{
$folder = new Folder();
$folder->setParentId(15);
$this->assertEquals(15, $folder->getParentId());
}
public function testSetUserId()
{
$folder = new Folder();
$folder->setUserId('15');
$this->assertEquals('15', $folder->getUserId());
}
}

View File

@ -29,7 +29,6 @@ class ItemTest extends TestCase
protected function setUp(): void
{
$this->item = new Item();
$this->item->setStatus(0);
}
@ -75,7 +74,6 @@ class ItemTest extends TestCase
$item->setTitle('title');
$item->setAuthor('author');
$item->setPubDate(123);
$item->setUpdatedDate(234);
$item->setBody('body');
$item->setEnclosureMime('audio/ogg');
$item->setEnclosureLink('enclink');
@ -83,7 +81,6 @@ class ItemTest extends TestCase
$item->setMediaDescription('The best video ever');
$item->setRtl(true);
$item->setFeedId(1);
$item->setStatus(0);
$item->setUnread(true);
$item->setStarred(true);
$item->setLastModified('1111111111234567');
@ -99,7 +96,7 @@ class ItemTest extends TestCase
'title' => 'title',
'author' => 'author',
'pubDate' => 123,
'updatedDate' => 234,
'updatedDate' => null,
'body' => 'body',
'enclosureMime' => 'audio/ogg',
'enclosureLink' => 'enclink',
@ -112,7 +109,8 @@ class ItemTest extends TestCase
'rtl' => true,
'fingerprint' => 'fingerprint',
'contentHash' => 'contentHash'
], $item->toAPI()
],
$item->toAPI()
);
}
@ -127,14 +125,12 @@ class ItemTest extends TestCase
$item->setTitle('title');
$item->setAuthor('author');
$item->setPubDate(123);
$item->setUpdatedDate(234);
$item->setBody('<body><div>this is a test</body>');
$item->setEnclosureMime('audio/ogg');
$item->setEnclosureLink('enclink');
$item->setMediaThumbnail('https://i2.ytimg.com/vi/E6B3uvhrcQk/hqdefault.jpg');
$item->setMediaDescription('The best video ever');
$item->setFeedId(1);
$item->setStatus(0);
$item->setRtl(true);
$item->setUnread(true);
$item->setFingerprint('fingerprint');
@ -150,7 +146,7 @@ class ItemTest extends TestCase
'title' => 'title',
'author' => 'author',
'pubDate' => 123,
'updatedDate' => 234,
'updatedDate' => null,
'body' => '<body><div>this is a test</body>',
'enclosureMime' => 'audio/ogg',
'enclosureLink' => 'enclink',
@ -177,7 +173,6 @@ class ItemTest extends TestCase
$item->setTitle('title');
$item->setAuthor('author');
$item->setPubDate(123);
$item->setUpdatedDate(234);
$item->setBody('body');
$item->setEnclosureMime('audio/ogg');
$item->setEnclosureLink('enclink');
@ -185,7 +180,6 @@ class ItemTest extends TestCase
$item->setMediaDescription('The best video ever');
$item->setFeedId(1);
$item->setRtl(true);
$item->setStatus(0);
$item->setUnread(false);
$item->setStarred(true);
$item->setLastModified(321);
@ -201,7 +195,7 @@ class ItemTest extends TestCase
'title' => 'title',
'author' => 'author',
'pubDate' => 123,
'updatedDate' => 234,
'updatedDate' => null,
'body' => 'body',
'enclosureMime' => 'audio/ogg',
'enclosureLink' => 'enclink',
@ -225,7 +219,6 @@ class ItemTest extends TestCase
$item->setTitle('title');
$item->setAuthor('author');
$item->setPubDate(123);
$item->setUpdatedDate(234);
$item->setBody('body');
$item->setEnclosureMime('audio/ogg');
$item->setEnclosureLink('enclink');
@ -265,7 +258,7 @@ class ItemTest extends TestCase
'title' => $item->getTitle(),
'author' => $item->getAuthor(),
'pubDate' => $item->getPubDate(),
'updatedDate' => $item->getUpdatedDate(),
'updatedDate' => null,
'body' => $item->getBody(),
'enclosureMime' => $item->getEnclosureMime(),
'enclosureLink' => $item->getEnclosureLink(),
@ -292,7 +285,7 @@ class ItemTest extends TestCase
'title' => $item->getTitle(),
'author' => $item->getAuthor(),
'pubDate' => $item->getPubDate(),
'updatedDate' => $item->getUpdatedDate(),
'updatedDate' => null,
'body' => $item->getBody(),
'enclosureMime' => $item->getEnclosureMime(),
'enclosureLink' => $item->getEnclosureLink(),

View File

@ -597,8 +597,7 @@ class FeedFetcherTest extends TestCase
->setRtl(false)
->setLastModified(3)
->setPubDate(3)
->setAuthor(html_entity_decode($this->author->getName()))
->setStatus(0);
->setAuthor(html_entity_decode($this->author->getName()));
if ($enclosureType === 'audio/ogg' || $enclosureType === 'video/ogg') {
$media = $this->getMockbuilder(MediaInterface::class)->getMock();

View File

@ -710,7 +710,6 @@ class FeedServiceTest extends TestCase
$feed = Feed::fromRow(
[
'id' => 3,
'http_etag' => 'a',
'http_last_modified' => 1,
'full_text_enabled' => false
]
@ -722,7 +721,6 @@ class FeedServiceTest extends TestCase
->willReturnOnConsecutiveCalls($this->returnValue($feed));
$feed2->setFullTextEnabled(false);
$feed2->setHttpEtag('a');
$feed2->setHttpLastModified('1');
$feed2->resetUpdatedFields();

View File

@ -308,12 +308,10 @@ class ItemServiceTest extends TestCase
$guidHash = md5('hihi');
$item = new Item();
$item->setStatus(128);
$item->setId($itemId);
$item->setStarred(true);
$expectedItem = new Item();
$expectedItem->setStatus(128);
$expectedItem->setStarred(true); //workaround to set starred as updated field
$expectedItem->setStarred(false);
$expectedItem->setId($itemId);
@ -336,12 +334,10 @@ class ItemServiceTest extends TestCase
{
$itemId = 3;
$item = new Item();
$item->setStatus(128);
$item->setId($itemId);
$item->setUnread(true);
$expectedItem = new Item();
$expectedItem->setStatus(128);
$expectedItem->setUnread(false);
$expectedItem->setId($itemId);
$expectedItem->setLastModified($this->time);