Add average company rating
This commit is contained in:
parent
5e442e8f72
commit
7098d6945f
@ -1,5 +1,5 @@
|
||||
component Rating(value float64, userCount int, user *arn.User)
|
||||
if user == nil
|
||||
.anime-rating.tip(aria-label="Rated by " + stringutils.Plural(userCount, "user"))= fmt.Sprintf("%.1f", value)
|
||||
.anime-rating.tip(aria-label="Based on " + stringutils.Plural(userCount, "rating"))= fmt.Sprintf("%.1f", value)
|
||||
else
|
||||
.anime-rating.tip(aria-label="Rated by " + stringutils.Plural(userCount, "user"))= fmt.Sprintf("%." + strconv.Itoa(user.Settings().Format.RatingsPrecision) + "f", value)
|
||||
.anime-rating.tip(aria-label="Based on " + stringutils.Plural(userCount, "rating"))= fmt.Sprintf("%." + strconv.Itoa(user.Settings().Format.RatingsPrecision) + "f", value)
|
@ -52,6 +52,28 @@ func Get(ctx aero.Context) error {
|
||||
var closeCompanies []*arn.Company
|
||||
distances := map[string]float64{}
|
||||
|
||||
var overallRating, storyRating, visualsRating, soundtrackRating float64
|
||||
var overallCount, storyCount, visualsCount, soundtrackCount int
|
||||
|
||||
for _, anime := range studioAnime {
|
||||
overallRating += anime.Rating.Overall
|
||||
storyRating += anime.Rating.Story
|
||||
visualsRating += anime.Rating.Visuals
|
||||
soundtrackRating += anime.Rating.Soundtrack
|
||||
|
||||
overallCount += anime.Rating.Count.Overall
|
||||
storyCount += anime.Rating.Count.Story
|
||||
visualsCount += anime.Rating.Count.Visuals
|
||||
soundtrackCount += anime.Rating.Count.Soundtrack
|
||||
}
|
||||
|
||||
totalStudioAnime := float64(len(studioAnime))
|
||||
|
||||
overallRating /= totalStudioAnime
|
||||
storyRating /= totalStudioAnime
|
||||
visualsRating /= totalStudioAnime
|
||||
soundtrackRating /= totalStudioAnime
|
||||
|
||||
if company.Location.IsValid() {
|
||||
closeCompanies = arn.FilterCompanies(func(closeCompany *arn.Company) bool {
|
||||
if closeCompany.ID == company.ID {
|
||||
@ -73,5 +95,5 @@ func Get(ctx aero.Context) error {
|
||||
})
|
||||
}
|
||||
|
||||
return ctx.HTML(components.CompanyPage(company, studioAnime, producedAnime, licensedAnime, closeCompanies, distances, user))
|
||||
return ctx.HTML(components.CompanyPage(company, studioAnime, producedAnime, licensedAnime, closeCompanies, distances, user, overallRating, storyRating, visualsRating, soundtrackRating, overallCount, storyCount, visualsCount, soundtrackCount))
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
component CompanyPage(company *arn.Company, studioAnime, producedAnime, licensedAnime []*arn.Anime, closeCompanies []*arn.Company, distances map[string]float64, user *arn.User)
|
||||
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)
|
||||
CompanyTabs(company, user)
|
||||
|
||||
.company-page
|
||||
@ -13,6 +13,30 @@ component CompanyPage(company *arn.Company, studioAnime, producedAnime, licensed
|
||||
CompanyAnimes("Licensed:", licensedAnime, user)
|
||||
|
||||
.company-sidebar
|
||||
h3.mountable Average Ratings:
|
||||
|
||||
table.company-rating-info-table
|
||||
tbody
|
||||
tr.mountable(data-mountable-type="ratings")
|
||||
td.company-rating-info-key Overall:
|
||||
td.company-rating-info-value
|
||||
Rating(overallRating, overallCount, user)
|
||||
|
||||
tr.mountable(data-mountable-type="ratings")
|
||||
td.company-rating-info-key Story:
|
||||
td.company-rating-info-value
|
||||
Rating(storyRating, storyCount, user)
|
||||
|
||||
tr.mountable(data-mountable-type="ratings")
|
||||
td.company-rating-info-key Visuals:
|
||||
td.company-rating-info-value
|
||||
Rating(visualsRating, visualsCount, user)
|
||||
|
||||
tr.mountable(data-mountable-type="ratings")
|
||||
td.company-rating-info-key Soundtrack:
|
||||
td.company-rating-info-value
|
||||
Rating(soundtrackRating, soundtrackCount, user)
|
||||
|
||||
if company.Location.Latitude != 0 && company.Location.Longitude != 0
|
||||
h3.mountable Location
|
||||
iframe.company-location.mountable(src="https://www.google.com/maps/embed/v1/place?q=" + fmt.Sprint(company.Location.Latitude) + "," + fmt.Sprint(company.Location.Longitude) + "&key=AIzaSyAsx6fhqRGaMLTixIJMIZBU4Mg6HJmvQf0", importance="low", title=company.Name.English + " location map")
|
||||
|
@ -40,4 +40,17 @@
|
||||
anime-mini-item
|
||||
|
||||
.company-anime-item-image
|
||||
anime-mini-item-image
|
||||
anime-mini-item-image
|
||||
|
||||
.company-rating-info-table
|
||||
vertical
|
||||
margin 0
|
||||
|
||||
tr
|
||||
horizontal
|
||||
|
||||
.company-rating-info-key
|
||||
flex 1
|
||||
|
||||
.company-rating-info-value
|
||||
text-align right
|
Loading…
Reference in New Issue
Block a user