Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LunchBunch
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ondřej Hrdlička
LunchBunch
Commits
7a40ef0b
There was an error fetching the commit references. Please try again later.
Commit
7a40ef0b
authored
1 year ago
by
Ondřej Hrdlička
Browse files
Options
Downloads
Patches
Plain Diff
feat: introduced more frontend-facing helper methods
parent
4cc08a4b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
internal/models/methods.go
+14
-0
14 additions, 0 deletions
internal/models/methods.go
with
14 additions
and
0 deletions
internal/models/methods.go
+
14
−
0
View file @
7a40ef0b
...
@@ -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
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment