mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
test(reader): ensure consistent tags parsing across feed formats
This commit is contained in:
parent
d6d18a2d61
commit
2e26f5ca75
7 changed files with 98 additions and 70 deletions
|
@ -8,8 +8,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"miniflux.app/v2/internal/crypto"
|
||||
|
@ -142,7 +140,7 @@ func (s *Storage) createEntry(tx *sql.Tx, entry *model.Entry) error {
|
|||
entry.UserID,
|
||||
entry.FeedID,
|
||||
entry.ReadingTime,
|
||||
pq.Array(removeEmpty(removeDuplicates(entry.Tags))),
|
||||
pq.Array(entry.Tags),
|
||||
).Scan(
|
||||
&entry.ID,
|
||||
&entry.Status,
|
||||
|
@ -198,7 +196,7 @@ func (s *Storage) updateEntry(tx *sql.Tx, entry *model.Entry) error {
|
|||
entry.UserID,
|
||||
entry.FeedID,
|
||||
entry.Hash,
|
||||
pq.Array(removeEmpty(removeDuplicates(entry.Tags))),
|
||||
pq.Array(entry.Tags),
|
||||
).Scan(&entry.ID)
|
||||
|
||||
if err != nil {
|
||||
|
@ -630,21 +628,6 @@ func (s *Storage) UnshareEntry(userID int64, entryID int64) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func removeDuplicates(l []string) []string {
|
||||
slices.Sort(l)
|
||||
return slices.Compact(l)
|
||||
}
|
||||
|
||||
func removeEmpty(l []string) []string {
|
||||
var finalSlice []string
|
||||
for _, item := range l {
|
||||
if strings.TrimSpace(item) != "" {
|
||||
finalSlice = append(finalSlice, item)
|
||||
}
|
||||
}
|
||||
return finalSlice
|
||||
}
|
||||
|
||||
func truncateString(s string) string {
|
||||
if len(s) > truncationLen {
|
||||
return s[:truncationLen]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue