From b816eb1d59d1f16a8f85d31d6b5ea2826648a332 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 18 Sep 2015 23:14:50 +0200 Subject: [PATCH 1/1] Let the SQL server filter notes --- lib/notestorage.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/notestorage.php b/lib/notestorage.php index 93311e4..27bb702 100644 --- a/lib/notestorage.php +++ b/lib/notestorage.php @@ -397,15 +397,18 @@ class NoteStorage public function loadNotesOverview( $since = null, $rawtag = null, $includeDate = false ) { - $result = \OC_DB::executeAudited( - 'SELECT `note_guid`, `note_title`, `note_last_sync_revision`, `note_tags`' + $sql = 'SELECT `note_guid`, `note_title`' + . ', `note_last_sync_revision`, `note_tags`' . ', `note_last_change_date`' . ' FROM `*PREFIX*grauphel_notes`' - . ' WHERE note_user = ?', - array($this->username) - ); + . ' WHERE note_user = ?'; + $sqlData = array($this->username); + + if ($since !== null) { + $sqlData[] = $since; + $sql .= ' AND note_last_sync_revision > ?'; + } - $notes = array(); if ($rawtag == 'grauphel:special:all') { $rawtag = null; } else if ($rawtag == 'grauphel:special:untagged') { @@ -413,13 +416,14 @@ class NoteStorage } else { $jsRawtag = json_encode($rawtag); } + if ($rawtag !== null) { + $sqlData[] = '%' . $jsRawtag . '%'; + $sql .= ' AND note_tags LIKE ?'; + } + + $result = \OC_DB::executeAudited($sql, $sqlData); + $notes = array(); while ($row = $result->fetchRow()) { - if ($since !== null && $row['note_last_sync_revision'] <= $since) { - continue; - } - if ($rawtag !== null && strpos($row['note_tags'], $jsRawtag) === false) { - continue; - } $note = array( 'guid' => $row['note_guid'], 'ref' => array( -- 2.30.2