fix парсер
This commit is contained in:
@@ -18,24 +18,31 @@ SET telegram_id = $2,
|
||||
title = $4,
|
||||
access_hash = $5,
|
||||
pts = $6,
|
||||
is_accessible = $7,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = $1;`
|
||||
|
||||
txOrPool := transaction.TryExtractTX(ctx)
|
||||
|
||||
username := strings.TrimSpace(channel.Username)
|
||||
usernameValid := username != ""
|
||||
|
||||
dto := updateChannelDTO{
|
||||
ID: pgtype.UUID{Bytes: channel.ID, Valid: true},
|
||||
TelegramID: pgtype.Int8{Int64: channel.TelegramID, Valid: true},
|
||||
Username: pgtype.Text{String: username, Valid: usernameValid},
|
||||
Title: pgtype.Text{String: channel.Title, Valid: true},
|
||||
AccessHash: pgtype.Int8{Int64: channel.AccessHash, Valid: true},
|
||||
Pts: pgtype.Int4{Int32: int32(channel.Pts), Valid: true},
|
||||
var usernameDTO pgtype.Text
|
||||
if username != "" {
|
||||
usernameDTO = pgtype.Text{String: username, Valid: true}
|
||||
} else {
|
||||
usernameDTO = pgtype.Text{Valid: false}
|
||||
}
|
||||
|
||||
_, err := txOrPool.Exec(ctx, query, dto.ID, dto.TelegramID, dto.Username, dto.Title, dto.AccessHash, dto.Pts)
|
||||
dto := updateChannelDTO{
|
||||
ID: pgtype.UUID{Bytes: channel.ID, Valid: true},
|
||||
TelegramID: pgtype.Int8{Int64: channel.TelegramID, Valid: true},
|
||||
Username: usernameDTO,
|
||||
Title: pgtype.Text{String: channel.Title, Valid: true},
|
||||
AccessHash: pgtype.Int8{Int64: channel.AccessHash, Valid: true},
|
||||
Pts: pgtype.Int4{Int32: int32(channel.Pts), Valid: true},
|
||||
IsAccessible: pgtype.Bool{Bool: channel.IsAccessible, Valid: true},
|
||||
}
|
||||
|
||||
_, err := txOrPool.Exec(ctx, query, dto.ID, dto.TelegramID, dto.Username, dto.Title, dto.AccessHash, dto.Pts, dto.IsAccessible)
|
||||
if err != nil {
|
||||
return fmt.Errorf("txOrPool.Exec: %w", err)
|
||||
}
|
||||
@@ -44,10 +51,11 @@ WHERE id = $1;`
|
||||
}
|
||||
|
||||
type updateChannelDTO struct {
|
||||
ID pgtype.UUID
|
||||
TelegramID pgtype.Int8
|
||||
Username pgtype.Text
|
||||
Title pgtype.Text
|
||||
AccessHash pgtype.Int8
|
||||
Pts pgtype.Int4
|
||||
ID pgtype.UUID
|
||||
TelegramID pgtype.Int8
|
||||
Username pgtype.Text
|
||||
Title pgtype.Text
|
||||
AccessHash pgtype.Int8
|
||||
Pts pgtype.Int4
|
||||
IsAccessible pgtype.Bool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user