diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2015-09-18 23:14:50 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2015-09-18 23:14:50 +0200 |
| commit | b816eb1d59d1f16a8f85d31d6b5ea2826648a332 (patch) | |
| tree | c180fa321879471f8621bf047e89df7542adbb23 /lib | |
| parent | 1a5b0cd1539c149d18db4e40f16c56654cace898 (diff) | |
| download | grauphel-b816eb1d59d1f16a8f85d31d6b5ea2826648a332.tar.gz grauphel-b816eb1d59d1f16a8f85d31d6b5ea2826648a332.zip | |
Let the SQL server filter notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/notestorage.php | 28 |
1 files 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( |
