Changes to the compse yml and the way and amout of artikeltexte are delivered and taht not duplicates are displayed
This commit is contained in:
@@ -206,7 +206,7 @@ func main() {
|
||||
if err := withConn(r, func(conn *pgx.Conn) error {
|
||||
|
||||
rows, err := conn.Query(r.Context(), `
|
||||
SELECT title, link, summary, image, published_at
|
||||
SELECT article_id, title, link, summary, image, published_at
|
||||
FROM articles
|
||||
WHERE image IS NOT NULL
|
||||
ORDER BY COALESCE(published_at, created_at) DESC
|
||||
@@ -238,16 +238,40 @@ func main() {
|
||||
w.Write([]byte("\n"))
|
||||
flusher.Flush()
|
||||
|
||||
seen := make(map[string]struct{})
|
||||
rowCount := 0
|
||||
|
||||
for rows.Next() {
|
||||
rowCount++
|
||||
var articleID *string
|
||||
var title, link, summary string
|
||||
var image *string
|
||||
var published *time.Time
|
||||
|
||||
if err := rows.Scan(&title, &link, &summary, &image, &published); err != nil {
|
||||
if err := rows.Scan(&articleID, &title, &link, &summary, &image, &published); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
id := ""
|
||||
if articleID != nil {
|
||||
id = strings.TrimSpace(*articleID)
|
||||
}
|
||||
if id == "" {
|
||||
if link != "" {
|
||||
id = link
|
||||
} else if title != "" {
|
||||
id = title
|
||||
} else {
|
||||
id = fmt.Sprintf("row:%d", rowCount)
|
||||
}
|
||||
}
|
||||
if _, exists := seen[id]; exists {
|
||||
continue
|
||||
}
|
||||
seen[id] = struct{}{}
|
||||
|
||||
item := map[string]interface{}{
|
||||
"id": id,
|
||||
"title": title,
|
||||
"link": link,
|
||||
"text": summary,
|
||||
|
||||
Reference in New Issue
Block a user