Skip to content
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

Merged
merged 5 commits into from
Jan 24, 2022
Merged

Conversation

linneamyl
Copy link
Contributor

No description provided.

@@ -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',
Copy link
Collaborator

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.

task_guid
)
if (old_task_entries) {
await Promise.all(
Copy link
Collaborator

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)

@MikaKattainen MikaKattainen merged commit b3f5ab6 into master Jan 24, 2022
@MikaKattainen MikaKattainen deleted the feature/database-refactor branch January 24, 2022 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants