diff options
| author | 2014-03-30 14:28:13 +0200 | |
|---|---|---|
| committer | 2014-03-30 14:28:13 +0200 | |
| commit | 779afe9c4ee00f8099a423e1fceee40197a90cfa (patch) | |
| tree | abfe8682ba0032711e0eba53eb615a248943a1bd /app/Models/EntryDAO.php | |
| parent | 9ea3819402746d8425d4a608f2d5f3c0f5bc29fb (diff) | |
Import of articles is implemented!
- Remove massiveImportAction and addCategories from FeedController
- Fix typo for some methods (camelCase)
- addCategoryObject and addFeedObject return id if corresponding object already
exists in DB
- introduce addEntryObject. Return -1 if Entry already exist (in order to keep
quite good performances)
- Complete importArticles method
Need some more tests + better performance
Diffstat (limited to 'app/Models/EntryDAO.php')
| -rw-r--r-- | app/Models/EntryDAO.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index e4cf128ea..6d00967fc 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -35,6 +35,36 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { } } + public function addEntryObject($entry, $conf, $feedHistory) { + $existingGuids = array_fill_keys( + $this->listLastGuidsByFeed($entry->feed(), 20), 1 + ); + + $nb_month_old = max($conf->old_entries, 1); + $date_min = time() - (3600 * 24 * 30 * $nb_month_old); + + $eDate = $entry->date(true); + + if ($feedHistory == -2) { + $feedHistory = $conf->keep_history_default; + } + + if (!isset($existingGuids[$entry->guid()]) && + ($feedHistory != 0 || $eDate >= $date_min)) { + $values = $entry->toArray(); + + $useDeclaredDate = empty($existingGuids); + $values['id'] = ($useDeclaredDate || $eDate < $date_min) ? + min(time(), $eDate) . uSecString() : + uTimeString(); + + return $this->addEntry($values); + } + + // We don't return Entry object to avoid a research in DB + return -1; + } + public function markFavorite($ids, $is_favorite = true) { if (!is_array($ids)) { $ids = array($ids); |
