-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathrepo_template.v
46 lines (34 loc) · 1.29 KB
/
repo_template.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module main
import veb
fn get_declension_form(count int, first_form string, second_form string) string {
if count == 1 {
return '<b>${count}</b> ${first_form}'
}
return '<b>${count}</b> ${second_form}'
}
fn (mut app App) format_commits_count(repo Repo, branch_name string) veb.RawHtml {
branch := app.find_repo_branch_by_name(repo.id, branch_name)
nr_commits := app.get_repo_commit_count(repo.id, branch.id)
return get_declension_form(nr_commits, 'Commit', 'Commits')
}
fn (r &Repo) format_nr_branches() veb.RawHtml {
return get_declension_form(r.nr_branches, 'Branch', 'Branches')
}
fn (r &Repo) format_nr_tags() veb.RawHtml {
return get_declension_form(r.nr_tags, 'Branch', 'Branches')
}
fn (r &Repo) format_nr_open_prs() veb.RawHtml {
return get_declension_form(r.nr_open_prs, 'Pull request', 'Pull requests')
}
fn (r &Repo) format_nr_open_issues() veb.RawHtml {
return get_declension_form(r.nr_open_issues, 'Issue', 'Issues')
}
fn (r &Repo) format_nr_contributors() veb.RawHtml {
return get_declension_form(r.nr_contributors, 'Contributor', 'Contributors')
}
fn (r &Repo) format_nr_topics() veb.RawHtml {
return get_declension_form(r.nr_topics, 'Discussion', 'discussions')
}
fn (r &Repo) format_nr_releases() veb.RawHtml {
return get_declension_form(r.nr_releases, 'Release', 'Releases')
}