mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
Optimize: bump to Go 1.21 and clean some code
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
module pixivfe
|
||||
|
||||
go 1.20
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/goccy/go-json v0.10.2
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ func (p *PixivClient) GetArtworkByID(id string) (*models.Illust, error) {
|
||||
sort.Sort(sort.Reverse(sort.IntSlice(ids)))
|
||||
|
||||
idsString := ""
|
||||
count := Min(len(ids), 30)
|
||||
count := min(len(ids), 30)
|
||||
|
||||
for i := 0; i < count; i++ {
|
||||
idsString += fmt.Sprintf("&ids[]=%d", ids[i])
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package handler
|
||||
|
||||
func Min(x, y int) int {
|
||||
if x < y {
|
||||
return x
|
||||
}
|
||||
return y
|
||||
}
|
||||
+1
-1
@@ -98,7 +98,7 @@ func (p *PixivClient) GetDiscoveryArtwork(mode string, count int) ([]models.Illu
|
||||
var artworks []models.IllustShort
|
||||
|
||||
for count > 0 {
|
||||
itemsForRequest := Min(100, count)
|
||||
itemsForRequest := min(100, count)
|
||||
|
||||
count -= itemsForRequest
|
||||
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ func (p *PixivClient) GetLandingPage(mode string) (models.LandingArtworks, error
|
||||
|
||||
for i := 0; i < len(pages.RecommendedByTags); i++ {
|
||||
temp := pages.RecommendedByTags[i]
|
||||
temp.Artworks = artworks.Artworks[count : count+Min(len(temp.Ids), 18)]
|
||||
temp.Artworks = artworks.Artworks[count : count+min(len(temp.Ids), 18)]
|
||||
|
||||
context.RecommendByTags = append(context.RecommendByTags, temp.LandingRecommendByTags)
|
||||
count += len(temp.Ids)
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ func (p *PixivClient) GetUserArtworksID(id string, category string, page int) (s
|
||||
}
|
||||
|
||||
start := (page - 1) * int(worksPerPage)
|
||||
end := int(math.Min(float64(page)*worksPerPage, worksNumber)) // no overflow
|
||||
end := int(min(float64(page)*worksPerPage, worksNumber)) // no overflow
|
||||
|
||||
for _, k := range ids[start:end] {
|
||||
idsString += fmt.Sprintf("&ids[]=%d", k)
|
||||
|
||||
Reference in New Issue
Block a user