diff --git a/assets/views/user.jet.html b/assets/views/user.jet.html index 69b2627..b45f799 100644 --- a/assets/views/user.jet.html +++ b/assets/views/user.jet.html @@ -132,6 +132,7 @@

Works{{ .User.WorkCounts.All }}

+ {*

Manga series{{ len(.User.MangaSeries) }}

@@ -139,6 +140,7 @@ {{- include "fragments/mangaseries-tn" . }} {{- end }}
+ *} {{ if len(.User.Illustrations) != 0 }} diff --git a/core/user.go b/core/user.go index f9d6453..e948615 100644 --- a/core/user.go +++ b/core/user.go @@ -106,11 +106,11 @@ type User struct { } // GetUserProfile retrieves the user profile, including counts, artworks/bookmarks, and social data. -func GetUserProfile(auditor *audit.Auditor, r *http.Request, id string, category *UserWorkCategory, page int, getTags bool) (User, error) { +func GetUserProfile(auditor *audit.Auditor, r *http.Request, id string, currentCategory *UserWorkCategory, page int, getTags bool) (User, error) { var user User auditor.Logger.Debug("GetUserProfile called", zap.String("userID", id), - zap.String("category", category.Value), + zap.String("currentCategory", currentCategory.Value), zap.Int("page", page), zap.Bool("getTags", getTags), ) @@ -139,9 +139,9 @@ func GetUserProfile(auditor *audit.Auditor, r *http.Request, id string, category } auditor.Logger.Debug("User information unmarshalled", zap.String("userName", user.Name)) - // Get populated works or bookmarks based on the category + // Get populated works or bookmarks based on the currentCategory auditor.Logger.Debug("Getting populated works") - if err := getPopulatedWorks(auditor, r, &user, id, category, page, getTags); err != nil { + if err := getPopulatedWorks(auditor, r, &user, id, currentCategory, page, getTags); err != nil { auditor.SugaredLogger.Error("Failed to get populated works", zap.Error(err)) return user, err } @@ -169,18 +169,18 @@ func GetUserProfile(auditor *audit.Auditor, r *http.Request, id string, category return user, nil } -// getPopulatedWorks fetches then populates information for a user's works or bookmarks, based on the category. +// getPopulatedWorks fetches then populates information for a user's works or bookmarks, based on the currentCategory. // // It also handles a user's frequently used tags and series data. -func getPopulatedWorks(auditor *audit.Auditor, r *http.Request, user *User, id string, category *UserWorkCategory, page int, getTags bool) error { +func getPopulatedWorks(auditor *audit.Auditor, r *http.Request, user *User, id string, currentCategory *UserWorkCategory, page int, getTags bool) error { auditor.Logger.Debug("getPopulatedWorks called", zap.String("userID", id), - zap.String("category", category.Value), + zap.String("currentCategory", currentCategory.Value), zap.Int("page", page), zap.Bool("getTags", getTags), ) - if category.Value == CategoryBookmarks.Value { + if currentCategory.Value == CategoryBookmarks.Value { auditor.Logger.Debug("Category is Bookmarks, fetching bookmarks") // Fetch bookmarks works, count, err := fetchBookmarks(auditor, r, id, "show", page) @@ -200,7 +200,7 @@ func getPopulatedWorks(auditor *audit.Auditor, r *http.Request, user *User, id s // Calculate PageLimit for bookmarks worksPerPage := 48.0 pageLimit := int(math.Ceil(float64(count) / worksPerPage)) - category.SetPageLimit(pageLimit) + currentCategory.SetPageLimit(pageLimit) auditor.Logger.Debug("PageLimit set for bookmarks", zap.Int("pageLimit", pageLimit)) return nil @@ -208,7 +208,7 @@ func getPopulatedWorks(auditor *audit.Auditor, r *http.Request, user *User, id s // Fetch work IDs and series data auditor.Logger.Debug("Fetching work IDs and series data for works") - userWorkIDs, countInfo, mangaSeriesData, novelSeriesData, err := fetchWorkIDsAndSeriesData(auditor, r, id, category, page) + userWorkIDs, countInfo, mangaSeriesData, novelSeriesData, err := fetchWorkIDsAndSeriesData(auditor, r, id, currentCategory, page) if err != nil { auditor.SugaredLogger.Error("Failed to fetch work IDs and series data", zap.Error(err)) return err @@ -221,7 +221,7 @@ func getPopulatedWorks(auditor *audit.Auditor, r *http.Request, user *User, id s // Initialize ID strings for different work types var illustrationIDs, mangaIDs, novelIDs string - switch category.Value { + switch currentCategory.Value { case CategoryIllustration.Value: illustrationIDs = userWorkIDs.IllustrationIDs auditor.Logger.Debug("Category is Illustration", zap.String("illustrationIDs", illustrationIDs)) @@ -242,8 +242,8 @@ func getPopulatedWorks(auditor *audit.Auditor, r *http.Request, user *User, id s zap.String("novelIDs", novelIDs), ) default: - auditor.SugaredLogger.Warn("Unsupported category", zap.String("category", category.Value)) - return fmt.Errorf("unsupported category: %v", category.Value) + auditor.SugaredLogger.Warn("Unsupported category", zap.String("category", currentCategory.Value)) + return fmt.Errorf("unsupported category: %v", currentCategory.Value) } // Early return if there are no works to fetch @@ -299,7 +299,7 @@ func getPopulatedWorks(auditor *audit.Auditor, r *http.Request, user *User, id s // Fetch a user's frequently used tags if requested if getTags { auditor.Logger.Debug("Fetching frequent tags") - user.FrequentTags, err = populateFrequentTags(auditor, r, id, category, illustrationIDs, mangaIDs, novelIDs) + user.FrequentTags, err = populateFrequentTags(auditor, r, id, currentCategory, illustrationIDs, mangaIDs, novelIDs) if err != nil { auditor.SugaredLogger.Error("Failed to populate frequent tags", zap.Error(err)) return err @@ -330,7 +330,7 @@ func populateFrequentTags( auditor *audit.Auditor, r *http.Request, id string, - category *UserWorkCategory, + currentCategory *UserWorkCategory, illustrationIDs string, mangaIDs string, novelIDs string, @@ -416,7 +416,7 @@ func populateFrequentTags( if len(finalTagsIDs) != 0 { // Concatenate IDs to form a single string ids := strings.Join(finalTagsIDs, "") - frequentTags, err := fetchFrequentTags(auditor, r, ids, category) + frequentTags, err := fetchFrequentTags(auditor, r, ids, currentCategory) if err != nil { return nil, fmt.Errorf("failed to get user frequent tags: %w", err) } @@ -425,7 +425,7 @@ func populateFrequentTags( auditor.Logger.Warn( "No tags found to fetch, setting FrequentTags to empty slice", - zap.String("category", category.Value), + zap.String("currentCategory", currentCategory.Value), zap.Strings("primaryTagsIDs", primaryTagsIDs), zap.Strings("secondaryTagsIDs", secondaryTagsIDs), zap.String("illustrationIDs", illustrationIDs), @@ -541,10 +541,10 @@ func extractIDs(rawMessage *json.RawMessage, categoryName string) ([]int, int, e // fetchWorkIDsAndSeriesData retrieves artwork IDs and series information for a user. // // It returns separate ID strings for illustrations, manga, and novels encapsulated in UserWorkIDs. -func fetchWorkIDsAndSeriesData(auditor *audit.Auditor, r *http.Request, id string, category *UserWorkCategory, page int) (userWorkIDs UserWorkIDs, workCounts WorkCounts, mangaSeriesData, novelSeriesData json.RawMessage, err error) { +func fetchWorkIDsAndSeriesData(auditor *audit.Auditor, r *http.Request, id string, currentCategory *UserWorkCategory, page int) (userWorkIDs UserWorkIDs, workCounts WorkCounts, mangaSeriesData, novelSeriesData json.RawMessage, err error) { auditor.Logger.Debug("fetchWorkIDsAndSeriesData called", zap.String("userID", id), - zap.String("category", category.Value), + zap.String("currentCategory", currentCategory.Value), zap.Int("page", page), ) @@ -702,13 +702,13 @@ func fetchWorkIDsAndSeriesData(auditor *audit.Auditor, r *http.Request, id strin } // Set PageLimit on the correct category - if subCategory.Value == category.Value { - category.SetPageLimit(pageLimit) + if subCategory.Value == currentCategory.Value { + currentCategory.SetPageLimit(pageLimit) auditor.Logger.Debug("PageLimit set for category", - zap.String("category", category.Value), + zap.String("category", currentCategory.Value), zap.Int("pageLimit", pageLimit), ) - } else if category.Value == "" || category.Value == "artworks" { + } else if currentCategory.Value == "" || currentCategory.Value == "artworks" { // For "any" or "artworks", accumulate total items and compute PageLimit later totalItemsForCategory += totalItems } @@ -783,12 +783,12 @@ func handleSeriesData(auditor *audit.Auditor, mangaSeriesData, novelSeriesData j } // fetchFrequentTags fetches a user's frequently used tags, based on category. -func fetchFrequentTags(auditor *audit.Auditor, r *http.Request, ids string, category *UserWorkCategory) ([]FrequentTag, error) { +func fetchFrequentTags(auditor *audit.Auditor, r *http.Request, ids string, currentCategory *UserWorkCategory) ([]FrequentTag, error) { var tags []FrequentTag var URL string // TODO: If overall, request both? - if category != &CategoryNovels { + if currentCategory != &CategoryNovels { URL = GetUserFrequentArtworkTagsURL(ids) } else { URL = GetUserFrequentNovelTagsURL(ids) diff --git a/i18n/locale/en/template.json b/i18n/locale/en/template.json index 2fe61f1..13fe7a3 100644 --- a/i18n/locale/en/template.json +++ b/i18n/locale/en/template.json @@ -543,7 +543,6 @@ "assets/views/unauthorized.jet.html:SNRVjaimXDQ": "You need to log in to use this feature.", "assets/views/user.jet.html:3_oq3Nw2b2U": "View on pixiv.net", "assets/views/user.jet.html:5xhgcv5yNyM": "Frequently used tags", - "assets/views/user.jet.html:818-yx2fz-M": "Manga series", "assets/views/user.jet.html:9EbrMpLP6_U": "Bookmarks", "assets/views/user.jet.html:Awt3bDxDL0U": "View more", "assets/views/user.jet.html:P6fO_UTqr7E": "Manga",