Adding everything to get started on cycle tracking and maybe avid habit clone
This commit is contained in:
1 parent
77cd95fdcb
commit
b51e5ac0d0
19 files changed
+1727
-333
No files matched your search
@@ -46,14 +46,17 @@ Attachment.textSearch = (userId, searchTerm) => {
|
||||
})
|
||||
}
|
||||
|
||||
Attachment.search = (userId, noteId, attachmentType, offset, setSize) => {
|
||||
Attachment.search = (userId, noteId, attachmentType, offset, setSize, includeShared) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
let params = [userId]
|
||||
let query = 'SELECT * FROM attachment WHERE user_id = ? AND visible = 1 '
|
||||
let query = `
|
||||
SELECT attachment.*, note.share_user_id FROM attachment
|
||||
JOIN note ON (attachment.note_id = note.id)
|
||||
WHERE attachment.user_id = ? AND visible = 1 `
|
||||
|
||||
if(noteId && noteId > 0){
|
||||
query += 'AND note_id = ? '
|
||||
query += 'AND attachment.note_id = ? '
|
||||
params.push(noteId)
|
||||
}
|
||||
|
||||
@@ -64,11 +67,16 @@ Attachment.search = (userId, noteId, attachmentType, offset, setSize) => {
|
||||
query += 'AND attachment_type > 1 '
|
||||
}
|
||||
|
||||
if(!noteId){
|
||||
const sharedOrNot = includeShared ? ' NOT ':' '
|
||||
query += `AND note.share_user_id IS${sharedOrNot}NULL `
|
||||
}
|
||||
|
||||
|
||||
query += 'ORDER BY last_indexed DESC '
|
||||
|
||||
const limitOffset = parseInt(offset, 10) || 0 //Either parse int, or use zero
|
||||
const parsedSetSize = parseInt(setSize, 10) || 20 //Either parse int, or use zero
|
||||
const parsedSetSize = parseInt(setSize, 10) || 20
|
||||
query += ` LIMIT ${limitOffset}, ${parsedSetSize}`
|
||||
|
||||
db.promise()
|
||||
|
||||
Reference in new issue
Block a user