-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/database refactor #34
Conversation
…ies_history table and deleted from task_entries
src/database/index.js
Outdated
@@ -22,6 +22,22 @@ export async function postTaskEntry(taskEntry) { | |||
} = taskEntry | |||
|
|||
try { | |||
const old_task_entries = await db.any( | |||
'SELECT * FROM task_entries WHERE task_guid = $1', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tähän pitää varmaan lisätä se käyttäjän tarkistus. Sama task_guid voi olla monta kertaa taulussa koska kahdella tai useammalla käyttäjällä voi olla samaan taskiin merkattu status. Me halutaan vaan sen requestissä olevan käyttäjän merkinnät sille taskille.
src/database/index.js
Outdated
task_guid | ||
) | ||
if (old_task_entries) { | ||
await Promise.all( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ehkä rikkoisin tän pienempiin osiin niin on helpompi lukea.
Jonnekin määrittelisin seuraavat funktiot
const archiveTaskEntry = async (entry) => {
await archiveTaskEntry(entry)
return await deleteTaskEntry(entry.id)
}
const deleteTaskEntry = (id) => {
return db.result(
'DELETE FROM task_entries WHERE id = $1',
entry.id
)
}
const deletePromises = old_task_entries.map(archiveTaskEntry)
await Promise.all(deletePromises)
No description provided.