Skip to content
Snippets Groups Projects
Commit 7a40ef0b authored by Ondřej Hrdlička's avatar Ondřej Hrdlička
Browse files

feat: introduced more frontend-facing helper methods

parent 4cc08a4b
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,20 @@ func totalVotesString(count uint) string { ...@@ -37,6 +37,20 @@ func totalVotesString(count uint) string {
return "votes" return "votes"
} }
func (receiver RestaurantSnapshot) PercentageOfVotes(restaurant Restaurant) uint {
return restaurant.TotalVotes() / receiver.TotalVotes() * 100
}
func (receiver RestaurantSnapshot) DateTimeCreated() string { func (receiver RestaurantSnapshot) DateTimeCreated() string {
return receiver.Datetime.Format(time.DateTime) return receiver.Datetime.Format(time.DateTime)
} }
func (receiver Restaurant) HasUserVoted(userID uint) bool {
for _, vote := range receiver.Votes {
if vote.UserID == userID {
return true
}
}
return false
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment