mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 22:32:33 +03:00
feat: make sage possible
This commit is contained in:
parent
10207952e2
commit
89487cda3b
@ -254,7 +254,7 @@ func UpdateThread(c *gin.Context) {
|
|||||||
if len(isSageField) != 0 {
|
if len(isSageField) != 0 {
|
||||||
isSageString = isSageField[0]
|
isSageString = isSageField[0]
|
||||||
}
|
}
|
||||||
isSage := isSageString == "true"
|
isSage := isSageString == "on"
|
||||||
|
|
||||||
conn, err := Db.Pool.Acquire(context.TODO())
|
conn, err := Db.Pool.Acquire(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -188,7 +188,7 @@ func (r *PostsRepository) CreateInTx(tx pgx.Tx, p Post) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// updating parent post `updated_at`
|
// updating parent post `updated_at`
|
||||||
if !p.IsParent {
|
if !p.IsParent && !p.IsSage {
|
||||||
sql = `
|
sql = `
|
||||||
UPDATE posts
|
UPDATE posts
|
||||||
SET updated_at = now()
|
SET updated_at = now()
|
||||||
@ -197,6 +197,8 @@ func (r *PostsRepository) CreateInTx(tx pgx.Tx, p Post) (int, error) {
|
|||||||
row := tx.QueryRow(context.TODO(), sql, p.ParentID)
|
row := tx.QueryRow(context.TODO(), sql, p.ParentID)
|
||||||
var msg string
|
var msg string
|
||||||
err = row.Scan(&msg)
|
err = row.Scan(&msg)
|
||||||
|
// UPDATE always return `no rows`
|
||||||
|
// so we need to check this condition
|
||||||
if err != nil && err != pgx.ErrNoRows {
|
if err != nil && err != pgx.ErrNoRows {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
{{ if ne .FirstPostID 0 }}
|
{{ if ne .FirstPostID 0 }}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<input class="form-check-input" type="checkbox" value="" id="postSage" name="sage">
|
<input class="form-check-input" type="checkbox" value="on" id="postSage" name="sage">
|
||||||
<label class="form-check-label" for="postSage">
|
<label class="form-check-label" for="postSage">
|
||||||
Sage
|
Sage
|
||||||
</label>
|
</label>
|
||||||
|
Loading…
Reference in New Issue
Block a user