🚨 Fix compile issue
This commit is contained in:
parent
37dc92dc43
commit
ce9d663bc3
@ -15,7 +15,9 @@ import (
|
||||
func listRecommendation(c *fiber.Ctx) error {
|
||||
const featuredMax = 5
|
||||
|
||||
posts, err := services.GetFeaturedPosts(featuredMax)
|
||||
var err error
|
||||
var posts []models.Post
|
||||
posts, err = services.GetFeaturedPosts(featuredMax)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
@ -31,7 +33,6 @@ func listRecommendation(c *fiber.Ctx) error {
|
||||
|
||||
tx := database.C.Where("id IN ?", postIdx)
|
||||
var newPosts []models.Post
|
||||
var err error
|
||||
if c.Get("X-API-Version", "1") == "2" {
|
||||
newPosts, err = queries.ListPost(tx, featuredMax, 0, "id ASC", userId)
|
||||
} else {
|
||||
@ -56,9 +57,8 @@ func listRecommendationShuffle(c *fiber.Ctx) error {
|
||||
take := c.QueryInt("take", 10)
|
||||
offset := c.QueryInt("offset", 0)
|
||||
|
||||
tx := database.C
|
||||
|
||||
var err error
|
||||
tx := database.C
|
||||
if tx, err = services.UniversalPostFilter(c, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -68,14 +68,14 @@ func listRecommendationShuffle(c *fiber.Ctx) error {
|
||||
userId = &user.ID
|
||||
}
|
||||
|
||||
var count int64
|
||||
countTx := tx
|
||||
count, err := services.CountPost(countTx)
|
||||
count, err = services.CountPost(countTx)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
var items []models.Post
|
||||
var err error
|
||||
if c.Get("X-API-Version", "1") == "2" {
|
||||
items, err = queries.ListPost(tx, take, offset, "RANDOM()", userId)
|
||||
} else {
|
||||
@ -111,7 +111,7 @@ func getRecommendationFeed(c *fiber.Ctx) error {
|
||||
userId = &user.ID
|
||||
}
|
||||
|
||||
entries, err := services.GetFeed(c, limit, userId, cursorTime)
|
||||
entries, err := queries.GetFeed(c, limit, userId, cursorTime)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package services
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -10,7 +10,7 @@ import (
|
||||
"git.solsynth.dev/hypernet/interactive/pkg/internal/database"
|
||||
"git.solsynth.dev/hypernet/interactive/pkg/internal/gap"
|
||||
"git.solsynth.dev/hypernet/interactive/pkg/internal/models"
|
||||
"git.solsynth.dev/hypernet/interactive/pkg/internal/services/queries"
|
||||
"git.solsynth.dev/hypernet/interactive/pkg/internal/services"
|
||||
"git.solsynth.dev/hypernet/interactive/pkg/proto"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
@ -38,7 +38,7 @@ func GetFeed(c *fiber.Ctx, limit int, user *uint, cursor *time.Time) ([]FeedEntr
|
||||
newsCount := int(math.Ceil(limitF * 0.25))
|
||||
|
||||
// Internal posts
|
||||
interTx, err := UniversalPostFilter(c, database.C)
|
||||
interTx, err := services.UniversalPostFilter(c, database.C)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to prepare load interactive posts: %v", err)
|
||||
}
|
||||
@ -83,9 +83,9 @@ func ListPostForFeed(tx *gorm.DB, limit int, user *uint, api string) ([]FeedEntr
|
||||
var posts []models.Post
|
||||
var err error
|
||||
if api == "2" {
|
||||
posts, err = queries.ListPost(tx, limit, -1, "published_at DESC", user)
|
||||
} else {
|
||||
posts, err = ListPost(tx, limit, -1, "published_at DESC", user)
|
||||
} else {
|
||||
posts, err = services.ListPost(tx, limit, -1, "published_at DESC", user)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -93,7 +93,7 @@ func ListPostForFeed(tx *gorm.DB, limit int, user *uint, api string) ([]FeedEntr
|
||||
entries := lo.Map(posts, func(post models.Post, _ int) FeedEntry {
|
||||
return FeedEntry{
|
||||
Type: "interactive.post",
|
||||
Data: TruncatePostContent(post),
|
||||
Data: services.TruncatePostContent(post),
|
||||
CreatedAt: post.CreatedAt,
|
||||
}
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user