Cleanup
This commit is contained in:
parent
287a1837e9
commit
2b9ea49c9b
@ -1,5 +1,11 @@
|
|||||||
component Rating(value float64, userCount int, user *arn.User)
|
component Rating(value float64, userCount int, user *arn.User)
|
||||||
if user == nil
|
if user == nil
|
||||||
.anime-rating.tip(aria-label="Based on " + stringutils.Plural(userCount, "rating"))= fmt.Sprintf("%.1f", value)
|
.anime-rating.tip(aria-label="Rated by " + stringutils.Plural(userCount, "user"))= fmt.Sprintf("%.1f", value)
|
||||||
else
|
else
|
||||||
.anime-rating.tip(aria-label="Based on " + stringutils.Plural(userCount, "rating"))= fmt.Sprintf("%." + strconv.Itoa(user.Settings().Format.RatingsPrecision) + "f", value)
|
.anime-rating.tip(aria-label="Rated by " + stringutils.Plural(userCount, "user"))= fmt.Sprintf("%." + strconv.Itoa(user.Settings().Format.RatingsPrecision) + "f", value)
|
||||||
|
|
||||||
|
component CompanyRating(value float64, ratingCount int, user *arn.User)
|
||||||
|
if user == nil
|
||||||
|
.anime-rating.tip(aria-label="Based on " + stringutils.Plural(ratingCount, "rating"))= fmt.Sprintf("%.1f", value)
|
||||||
|
else
|
||||||
|
.anime-rating.tip(aria-label="Based on " + stringutils.Plural(ratingCount, "rating"))= fmt.Sprintf("%." + strconv.Itoa(user.Settings().Format.RatingsPrecision) + "f", value)
|
@ -52,27 +52,27 @@ func Get(ctx aero.Context) error {
|
|||||||
var closeCompanies []*arn.Company
|
var closeCompanies []*arn.Company
|
||||||
distances := map[string]float64{}
|
distances := map[string]float64{}
|
||||||
|
|
||||||
var overallRating, storyRating, visualsRating, soundtrackRating float64
|
// Average rating
|
||||||
var overallCount, storyCount, visualsCount, soundtrackCount int
|
rating := &arn.AnimeRating{}
|
||||||
|
|
||||||
for _, anime := range studioAnime {
|
for _, anime := range studioAnime {
|
||||||
overallRating += anime.Rating.Overall
|
rating.Overall += anime.Rating.Overall
|
||||||
storyRating += anime.Rating.Story
|
rating.Story += anime.Rating.Story
|
||||||
visualsRating += anime.Rating.Visuals
|
rating.Visuals += anime.Rating.Visuals
|
||||||
soundtrackRating += anime.Rating.Soundtrack
|
rating.Soundtrack += anime.Rating.Soundtrack
|
||||||
|
|
||||||
overallCount += anime.Rating.Count.Overall
|
rating.Count.Overall += anime.Rating.Count.Overall
|
||||||
storyCount += anime.Rating.Count.Story
|
rating.Count.Story += anime.Rating.Count.Story
|
||||||
visualsCount += anime.Rating.Count.Visuals
|
rating.Count.Visuals += anime.Rating.Count.Visuals
|
||||||
soundtrackCount += anime.Rating.Count.Soundtrack
|
rating.Count.Soundtrack += anime.Rating.Count.Soundtrack
|
||||||
}
|
}
|
||||||
|
|
||||||
totalStudioAnime := float64(len(studioAnime))
|
totalStudioAnime := float64(len(studioAnime))
|
||||||
|
|
||||||
overallRating /= totalStudioAnime
|
rating.Overall /= totalStudioAnime
|
||||||
storyRating /= totalStudioAnime
|
rating.Story /= totalStudioAnime
|
||||||
visualsRating /= totalStudioAnime
|
rating.Visuals /= totalStudioAnime
|
||||||
soundtrackRating /= totalStudioAnime
|
rating.Soundtrack /= totalStudioAnime
|
||||||
|
|
||||||
if company.Location.IsValid() {
|
if company.Location.IsValid() {
|
||||||
closeCompanies = arn.FilterCompanies(func(closeCompany *arn.Company) bool {
|
closeCompanies = arn.FilterCompanies(func(closeCompany *arn.Company) bool {
|
||||||
@ -95,5 +95,5 @@ func Get(ctx aero.Context) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML(components.CompanyPage(company, studioAnime, producedAnime, licensedAnime, closeCompanies, distances, user, overallRating, storyRating, visualsRating, soundtrackRating, overallCount, storyCount, visualsCount, soundtrackCount))
|
return ctx.HTML(components.CompanyPage(company, studioAnime, producedAnime, licensedAnime, closeCompanies, distances, rating, user))
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
component CompanyPage(company *arn.Company, studioAnime, producedAnime, licensedAnime []*arn.Anime, closeCompanies []*arn.Company, distances map[string]float64, user *arn.User, overallRating float64, storyRating float64, visualsRating float64, soundtrackRating float64, overallCount int, storyCount int, visualsCount int, soundtrackCount int)
|
component CompanyPage(company *arn.Company, studioAnime, producedAnime, licensedAnime []*arn.Anime, closeCompanies []*arn.Company, distances map[string]float64, rating *arn.AnimeRating, user *arn.User)
|
||||||
CompanyTabs(company, user)
|
CompanyTabs(company, user)
|
||||||
|
|
||||||
.company-page
|
.company-page
|
||||||
@ -13,29 +13,29 @@ component CompanyPage(company *arn.Company, studioAnime, producedAnime, licensed
|
|||||||
CompanyAnimes("Licensed:", licensedAnime, user)
|
CompanyAnimes("Licensed:", licensedAnime, user)
|
||||||
|
|
||||||
.company-sidebar
|
.company-sidebar
|
||||||
h3.mountable Average Ratings:
|
h3.mountable Ratings
|
||||||
|
|
||||||
table.company-rating-info-table
|
table.company-rating-info-table.mountable
|
||||||
tbody
|
tbody
|
||||||
tr.mountable(data-mountable-type="ratings")
|
tr.mountable
|
||||||
td.company-rating-info-key Overall:
|
td.company-rating-info-key Overall:
|
||||||
td.company-rating-info-value
|
td.company-rating-info-value
|
||||||
Rating(overallRating, overallCount, user)
|
CompanyRating(rating.Overall, rating.Count.Overall, user)
|
||||||
|
|
||||||
tr.mountable(data-mountable-type="ratings")
|
tr.mountable
|
||||||
td.company-rating-info-key Story:
|
td.company-rating-info-key Story:
|
||||||
td.company-rating-info-value
|
td.company-rating-info-value
|
||||||
Rating(storyRating, storyCount, user)
|
CompanyRating(rating.Story, rating.Count.Story, user)
|
||||||
|
|
||||||
tr.mountable(data-mountable-type="ratings")
|
tr.mountable
|
||||||
td.company-rating-info-key Visuals:
|
td.company-rating-info-key Visuals:
|
||||||
td.company-rating-info-value
|
td.company-rating-info-value
|
||||||
Rating(visualsRating, visualsCount, user)
|
CompanyRating(rating.Visuals, rating.Count.Visuals, user)
|
||||||
|
|
||||||
tr.mountable(data-mountable-type="ratings")
|
tr.mountable
|
||||||
td.company-rating-info-key Soundtrack:
|
td.company-rating-info-key Soundtrack:
|
||||||
td.company-rating-info-value
|
td.company-rating-info-value
|
||||||
Rating(soundtrackRating, soundtrackCount, user)
|
CompanyRating(rating.Soundtrack, rating.Count.Soundtrack, user)
|
||||||
|
|
||||||
if company.Location.Latitude != 0 && company.Location.Longitude != 0
|
if company.Location.Latitude != 0 && company.Location.Longitude != 0
|
||||||
h3.mountable Location
|
h3.mountable Location
|
||||||
|
Loading…
Reference in New Issue
Block a user