Skip to content

Commit 28a4de3

Browse files
committed
simplify files
1 parent bbb3bf8 commit 28a4de3

38 files changed

+241
-273
lines changed

src/activity_service.v renamed to src/activity.v

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ module main
22

33
import time
44

5+
struct Activity {
6+
mut:
7+
id int [primary; sql: serial]
8+
user_id int
9+
name string
10+
created_at time.Time
11+
}
12+
513
fn (app App) add_activity(user_id int, name string) ! {
614
activity := Activity{
715
user_id: user_id

src/activity_entities.v

Lines changed: 0 additions & 11 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/branch_service.v renamed to src/branch.v

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ module main
33
import time
44
import git
55

6+
struct Branch {
7+
mut:
8+
id int [primary; sql: serial]
9+
repo_id int [unique: 'branch']
10+
name string [unique: 'branch']
11+
author string // author of latest commit on branch
12+
hash string // hash of latest commit on branch
13+
date int // time of latest commit on branch
14+
}
15+
616
fn (mut app App) fetch_branches(repo Repo) ! {
717
branches_output := repo.git('branch -a')
818

src/branch_entities.v

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/commit_service.v renamed to src/commit.v

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ module main
44

55
import time
66

7+
struct Commit {
8+
mut:
9+
id int [primary; sql: serial]
10+
author_id int
11+
author string
12+
hash string [unique: 'commit']
13+
created_at int
14+
repo_id int [unique: 'commit']
15+
branch_id int [unique: 'commit']
16+
message string
17+
}
18+
19+
struct Change {
20+
mut:
21+
file string
22+
additions int
23+
deletions int
24+
diff string
25+
message string
26+
}
27+
728
fn (commit Commit) relative() string {
829
return time.unix(commit.created_at).relative()
930
}

src/commit_entities.v

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/feed_service.v renamed to src/feed.v

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ module main
22

33
import time
44

5+
// now only for commits
6+
struct FeedItem {
7+
id int
8+
author_name string
9+
created_at time.Time
10+
repo_name string
11+
repo_owner string
12+
branch_name string
13+
message string
14+
}
15+
516
const (
617
feed_items_per_page = 30
718
)

src/feed_entities.v

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/file_service.v renamed to src/file.v

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ import time
44
import math
55
import os
66

7+
struct File {
8+
id int [primary; sql: serial]
9+
repo_id int [unique: 'file']
10+
name string [unique: 'file']
11+
parent_path string [unique: 'file']
12+
is_dir bool
13+
branch string [unique: 'file']
14+
contributors_count int
15+
last_hash string
16+
size int
17+
views_count int
18+
mut:
19+
last_msg string
20+
last_time int
21+
commit Commit [skip]
22+
}
23+
724
fn (f File) url() string {
825
file_type := if f.is_dir { 'tree' } else { 'blob' }
926

src/file_entities.v

Lines changed: 0 additions & 20 deletions
This file was deleted.
File renamed without changes.

src/github_routes.v renamed to src/github.v

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ import vweb
66
import json
77
import net.http
88

9+
struct OAuthRequest {
10+
client_id string
11+
client_secret string
12+
code string
13+
state string
14+
}
15+
16+
struct GitHubUser {
17+
username string [json: 'login']
18+
name string
19+
email string
20+
avatar string [json: 'avatar_url']
21+
}
22+
923
['/oauth']
1024
pub fn (mut app App) handle_oauth() vweb.Result {
1125
code := app.query['code']

src/github_entities.v

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/lang_stats_service.v renamed to src/lang_stats.v

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ module main
22

33
import vweb
44

5+
struct LangStat {
6+
id int [primary; sql: serial]
7+
repo_id int [unique: 'langstat']
8+
name string [unique: 'langstat']
9+
lines_count int
10+
pct int // out of 1000
11+
color string
12+
}
13+
514
const (
615
test_lang_stats = [
716
LangStat{

src/lang_stats_entities.v

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/release_service.v renamed to src/release.v

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ module main
22

33
import time
44

5+
struct Release {
6+
id int [primary; sql: serial]
7+
repo_id int [unique: 'release']
8+
mut:
9+
tag_id int [unique: 'release']
10+
notes string
11+
tag_name string [skip]
12+
tag_hash string [skip]
13+
user string [skip]
14+
date time.Time
15+
}
16+
517
pub fn (mut app App) add_release(tag_id int, repo_id int, date time.Time, notes string) ! {
618
release := Release{
719
tag_id: tag_id

src/release_entities.v

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/repo_service.v renamed to src/repo.v

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,38 @@ import git
88
import highlight
99
import validation
1010

11+
struct Repo {
12+
id int [primary; sql: serial]
13+
git_dir string
14+
name string
15+
user_id int
16+
user_name string
17+
clone_url string [skip]
18+
primary_branch string
19+
description string
20+
is_public bool
21+
users_contributed []string [skip]
22+
users_authorized []string [skip]
23+
topics_count int [skip]
24+
views_count int
25+
latest_update_hash string [skip]
26+
latest_activity time.Time [skip]
27+
mut:
28+
webhook_secret string
29+
tags_count int
30+
open_issues_count int
31+
open_prs_count int
32+
releases_count int
33+
branches_count int
34+
stars_count int
35+
lang_stats []LangStat [skip]
36+
created_at int
37+
contributors_count int
38+
labels []Label [skip]
39+
status RepoStatus [skip]
40+
msg_cache map[string]string [skip]
41+
}
42+
1143
// log_field_separator is declared as constant in case we need to change it later
1244
const (
1345
max_git_res_size = 1000

src/repo_entities.v

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/security_log_service.v renamed to src/security_log.v

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@
22
// Use of this source code is governed by a GPL license that can be found in the LICENSE file.
33
module main
44

5+
enum SecurityLogKind {
6+
registered
7+
logged_in
8+
registered_via_github
9+
logged_in_via_github
10+
wrong_password
11+
wrong_oauth_state
12+
empty_oauth_code
13+
empty_oauth_email
14+
}
15+
16+
struct SecurityLog {
17+
id int [primary; sql: serial]
18+
user_id int
19+
kind_id int
20+
ip string
21+
arg1 string
22+
arg2 string
23+
created_at int
24+
mut:
25+
kind SecurityLogKind [skip]
26+
}
27+
528
fn (mut app App) add_security_log(log SecurityLog) ! {
629
new_log := SecurityLog{
730
...log

0 commit comments

Comments
 (0)