Skip to content

Commit 92bb280

Browse files
committed
make compile
1 parent 8a191ae commit 92bb280

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

highlight/highlight.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn highlight_text(st string, file_path string, commit bool) (string, int, in
2323
mut res := []u8{cap: text.len}
2424
mut lines := 0
2525
mut sloc := 0
26-
mut ss := byte(` `)
26+
mut ss := u8(` `)
2727
lc := lang.line_comments
2828
mut mlc := ''
2929
mut mlc_end := ''

src/feed_service.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ fn (mut app App) build_user_feed_as_page(user_id int, offset int) []FeedItem {
1111
repo_ids := app.find_watching_repo_ids(user_id)
1212
where_repo_ids := repo_ids.map(it.str()).join(', ')
1313

14-
commits, _ := app.db.exec('
14+
commits := app.db.exec('
1515
select author, hash, created_at, repo_id, branch_id, message from `Commit`
1616
where repo_id in (${where_repo_ids}) order by created_at desc
17-
limit ${feed_items_per_page} offset ${offset}')
17+
limit ${feed_items_per_page} offset ${offset}') or { return [] }
1818
mut item_id := 0
1919

2020
for commit in commits {
@@ -51,7 +51,7 @@ fn (mut app App) get_feed_items_count(user_id int) int {
5151
repo_ids := app.find_watching_repo_ids(user_id)
5252
where_repo_ids := repo_ids.map(it.str()).join(', ')
5353

54-
count_result, _ := app.db.exec('select count(id) from `Commit` where repo_id in (${where_repo_ids})')
54+
count_result := app.db.exec('select count(id) from `Commit` where repo_id in (${where_repo_ids})') or { return 0 }
5555

5656
return count_result.first().vals.first().int()
5757
}

src/repo_service.v

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ fn (mut app App) find_user_public_repos(user_id int) []Repo {
9696
}
9797

9898
fn (app App) search_public_repos(query string) []Repo {
99-
repo_rows, _ := app.db.exec('select id, name, user_id, description, stars_count from `Repo` where is_public is true and name like "%${query}%"')
99+
repo_rows := app.db.exec('select id, name, user_id, description, stars_count from `Repo` where is_public is true and name like "%${query}%"') or {
100+
return []
101+
}
100102

101103
mut repos := []Repo{}
102104

@@ -216,7 +218,7 @@ fn (mut app App) user_has_repo(user_id int, repo_name string) bool {
216218
fn (mut app App) update_repo_from_fs(mut repo Repo) ! {
217219
repo_id := repo.id
218220

219-
app.db.exec('BEGIN TRANSACTION')
221+
app.db.exec('BEGIN TRANSACTION')!
220222

221223
repo.analyse_lang(app)!
222224

@@ -242,7 +244,7 @@ fn (mut app App) update_repo_from_fs(mut repo Repo) ! {
242244
}
243245

244246
app.save_repo(repo)!
245-
app.db.exec('END TRANSACTION')
247+
app.db.exec('END TRANSACTION')!
246248
app.info('Repo updated')
247249
}
248250

@@ -291,7 +293,7 @@ fn (mut app App) update_repo_from_remote(mut repo Repo) ! {
291293
repo.git('fetch --all')
292294
repo.git('pull --all')
293295

294-
app.db.exec('BEGIN TRANSACTION')
296+
app.db.exec('BEGIN TRANSACTION')!
295297

296298
repo.analyse_lang(app)!
297299

@@ -317,7 +319,7 @@ fn (mut app App) update_repo_from_remote(mut repo Repo) ! {
317319
repo.branches_count = app.get_count_repo_branches(repo_id)
318320

319321
app.save_repo(repo)!
320-
app.db.exec('END TRANSACTION')
322+
app.db.exec('END TRANSACTION')!
321323
app.info('Repo updated')
322324
}
323325

@@ -580,7 +582,7 @@ fn (mut app App) cache_repository_items(mut r Repo, branch string, path string)
580582
mut dirs := []File{} // dirs first
581583
mut files := []File{}
582584

583-
app.db.exec('BEGIN TRANSACTION')
585+
app.db.exec('BEGIN TRANSACTION')!
584586

585587
for item_info in item_info_lines {
586588
is_item_info_empty := validation.is_string_empty(item_info)
@@ -608,7 +610,7 @@ fn (mut app App) cache_repository_items(mut r Repo, branch string, path string)
608610
app.add_file(file)!
609611
}
610612

611-
app.db.exec('END TRANSACTION')
613+
app.db.exec('END TRANSACTION')!
612614

613615
return dirs
614616
}

src/user_service.v

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ pub fn (mut app App) get_all_registered_user_count() int {
250250
}
251251

252252
fn (app App) search_users(query string) []User {
253-
repo_rows, _ := app.db.exec('select id, full_name, username, avatar from `User` where is_blocked is false and (username like "%${query}%" or full_name like "%${query}%")')
254-
253+
q := 'select id, full_name, username, avatar from `User` where is_blocked is false and ' +
254+
'(username like "%${query}%" or full_name like "%${query}%")'
255+
repo_rows := app.db.exec(q) or { return [] }
255256
mut users := []User{}
256-
257257
for row in repo_rows {
258258
users << User{
259259
id: row.vals[0].int()
@@ -262,7 +262,6 @@ fn (app App) search_users(query string) []User {
262262
avatar: row.vals[3]
263263
}
264264
}
265-
266265
return users
267266
}
268267

0 commit comments

Comments
 (0)