From 21f804cafbc11d6d750a4c84669bde529978a1d1 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Sat, 20 Nov 2021 22:42:16 +0200 Subject: [PATCH] feat: archive only parents --- README.md | 7 ++++--- repositories/posts_repository.go | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 71ca051..02736cc 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ Go tryout. Single board imageboard. ## Prerequisites -Create db. -Run migrations from `migrations`. -Create `.env` file from `.env.example`, change env vars to your needs. \ No newline at end of file +1. Go 1.13+. +2. PostgreSQL. +3. Create `.env` file from `.env.example`, change env vars to your needs. +4. Create db with the name that is specified in `.env` file in `POSTGRES_URL` env var. diff --git a/repositories/posts_repository.go b/repositories/posts_repository.go index b02d4c4..2817c3c 100644 --- a/repositories/posts_repository.go +++ b/repositories/posts_repository.go @@ -236,8 +236,9 @@ func (r *PostsRepository) ArchiveThreadsFrom(t time.Time) error { sql := ` UPDATE posts SET is_archived = true - WHERE - is_archived != true + WHERE + is_parent = true + AND is_archived != true AND updated_at <= $1 `