|
@@ -88,8 +88,8 @@ type User struct {
|
|
|
Social map[string]map[string]string
|
|
|
BackgroundImage string
|
|
|
|
|
|
- // Artworks, Illustrations, Manga, Novels, NovelSeries, MangaSeries have all been removed
|
|
|
- // Categories now holds all category-related data
|
|
|
+ // Categories holds all category-related data,
|
|
|
+ // including Artworks, Illustrations, Manga, Novels, NovelSeries, MangaSeries
|
|
|
Categories map[string]*UserWorkCategory
|
|
|
|
|
|
IsFollowed bool `json:"isFollowed"` // Denotes whether the logged in user is currently following the given user
|
|
@@ -119,8 +119,6 @@ func GetUserProfile(auditor *audit.Auditor, r *http.Request, id string, currentC
|
|
|
return user, err
|
|
|
}
|
|
|
|
|
|
- auditor.Logger.Debug("User information fetched successfully", zap.String("response", resp))
|
|
|
-
|
|
|
resp, err = session.ProxyImageUrl(r, resp)
|
|
|
if err != nil {
|
|
|
auditor.SugaredLogger.Error("Failed to proxy image URL", zap.Error(err))
|
|
@@ -131,7 +129,6 @@ func GetUserProfile(auditor *audit.Auditor, r *http.Request, id string, currentC
|
|
|
auditor.SugaredLogger.Error("Failed to unmarshal user information", zap.Error(err))
|
|
|
return user, err
|
|
|
}
|
|
|
- auditor.Logger.Debug("User information unmarshalled", zap.String("userName", user.Name))
|
|
|
|
|
|
// Initialize the user categories
|
|
|
user.Categories = map[string]*UserWorkCategory{
|
|
@@ -147,7 +144,6 @@ func GetUserProfile(auditor *audit.Auditor, r *http.Request, id string, currentC
|
|
|
auditor.SugaredLogger.Error("Failed to get populated works", zap.Error(err))
|
|
|
return user, err
|
|
|
}
|
|
|
- auditor.Logger.Debug("Populated works retrieved")
|
|
|
|
|
|
// Parse social data
|
|
|
auditor.Logger.Debug("Parsing social data")
|
|
@@ -167,7 +163,6 @@ func GetUserProfile(auditor *audit.Auditor, r *http.Request, id string, currentC
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- auditor.Logger.Debug("GetUserProfile completed successfully", zap.String("userID", user.ID))
|
|
|
return user, nil
|
|
|
}
|
|
|
|
|
@@ -189,9 +184,8 @@ func getPopulatedWorks(auditor *audit.Auditor, r *http.Request, user *User, id s
|
|
|
auditor.SugaredLogger.Error("Failed to fetch work IDs and series data", zap.Error(err))
|
|
|
return err
|
|
|
}
|
|
|
- auditor.Logger.Debug("Work IDs and series data fetched")
|
|
|
|
|
|
- // Update user.Categories with the fetched data
|
|
|
+ // Update user.Categories with the fetched IDs and series data
|
|
|
for name, catData := range categoriesData {
|
|
|
user.Categories[name] = catData
|
|
|
}
|
|
@@ -234,14 +228,6 @@ func getPopulatedWorks(auditor *audit.Auditor, r *http.Request, user *User, id s
|
|
|
cat.PageLimit = int(math.Ceil(float64(count) / worksPerPage))
|
|
|
}
|
|
|
|
|
|
- // Handle series data
|
|
|
- if cat.Value == "manga" && len(cat.MangaSeries) > 0 {
|
|
|
- auditor.Logger.Debug("Handling MangaSeries data", zap.Int("count", len(cat.MangaSeries)))
|
|
|
- }
|
|
|
- if cat.Value == "novels" && len(cat.NovelSeries) > 0 {
|
|
|
- auditor.Logger.Debug("Handling NovelSeries data", zap.Int("count", len(cat.NovelSeries)))
|
|
|
- }
|
|
|
-
|
|
|
// Fetch frequent tags if requested
|
|
|
if getTags && cat.Value != "bookmarks" {
|
|
|
auditor.Logger.Debug("Fetching frequent tags for category", zap.String("category", cat.Value))
|
|
@@ -370,14 +356,30 @@ func buildIDString(auditor *audit.Auditor, ids []int, page int, currentCategory,
|
|
|
sort.Sort(sort.Reverse(sort.IntSlice(ids)))
|
|
|
worksPerPage := 30.0
|
|
|
totalItems := len(ids)
|
|
|
- start, end, pageLimit, err := computeSliceBounds(auditor, page, worksPerPage, totalItems)
|
|
|
+
|
|
|
+ // We only use the actual page number for the current category being viewed
|
|
|
+ // and default the page to 1 for other categories.
|
|
|
+ //
|
|
|
+ // This is so that we don't attempt to paginate categories that don't have enough
|
|
|
+ // items, which would raise a spurious error from computeSliceBounds regarding an
|
|
|
+ // invalid page number.
|
|
|
+ //
|
|
|
+ // NOTE: A different approach will be needed if we require pageLimits for inactive categories.
|
|
|
+ effectivePage := page
|
|
|
+ if currentCategory.Value != cat.Value {
|
|
|
+ effectivePage = 1
|
|
|
+ }
|
|
|
+
|
|
|
+ start, end, pageLimit, err := computeSliceBounds(auditor, effectivePage, worksPerPage, totalItems)
|
|
|
if err != nil {
|
|
|
auditor.SugaredLogger.Error("Error computing slice bounds", zap.Error(err))
|
|
|
return ""
|
|
|
}
|
|
|
+
|
|
|
if currentCategory.Value == cat.Value {
|
|
|
cat.SetPageLimit(pageLimit)
|
|
|
}
|
|
|
+
|
|
|
idsToUse := ids[start:end]
|
|
|
var idsBuilder strings.Builder
|
|
|
for _, k := range idsToUse {
|