diff --git a/highlight/highlight.v b/highlight/highlight.v index d47e49a1..330b5731 100644 --- a/highlight/highlight.v +++ b/highlight/highlight.v @@ -23,7 +23,7 @@ pub fn highlight_text(st string, file_path string, commit bool) (string, int, in mut res := []u8{cap: text.len} mut lines := 0 mut sloc := 0 - mut ss := byte(` `) + mut ss := u8(` `) lc := lang.line_comments mut mlc := '' mut mlc_end := '' diff --git a/src/feed_service.v b/src/feed_service.v index 4a5b78a4..bbb2195b 100644 --- a/src/feed_service.v +++ b/src/feed_service.v @@ -11,10 +11,13 @@ fn (mut app App) build_user_feed_as_page(user_id int, offset int) []FeedItem { repo_ids := app.find_watching_repo_ids(user_id) where_repo_ids := repo_ids.map(it.str()).join(', ') - commits, _ := app.db.exec(' + commits:= app.db.exec(' select author, hash, created_at, repo_id, branch_id, message from `Commit` where repo_id in (${where_repo_ids}) order by created_at desc - limit ${feed_items_per_page} offset ${offset}') + limit ${feed_items_per_page} offset ${offset}') or { + return feed + } + mut item_id := 0 for commit in commits { @@ -51,7 +54,9 @@ fn (mut app App) get_feed_items_count(user_id int) int { repo_ids := app.find_watching_repo_ids(user_id) where_repo_ids := repo_ids.map(it.str()).join(', ') - count_result, _ := app.db.exec('select count(id) from `Commit` where repo_id in (${where_repo_ids})') + count_result:= app.db.exec('select count(id) from `Commit` where repo_id in (${where_repo_ids})') or { + return 0 + } return count_result.first().vals.first().int() } diff --git a/src/repo_service.v b/src/repo_service.v index 3c33f426..87960069 100644 --- a/src/repo_service.v +++ b/src/repo_service.v @@ -96,10 +96,12 @@ fn (mut app App) find_user_public_repos(user_id int) []Repo { } fn (app App) search_public_repos(query string) []Repo { - repo_rows, _ := app.db.exec('select id, name, user_id, description, stars_count from `Repo` where is_public is true and name like "%${query}%"') - mut repos := []Repo{} + 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 { + return repos + } + for row in repo_rows { user_id := row.vals[2].int() user := app.get_user_by_id(user_id) or { User{} } @@ -216,7 +218,7 @@ fn (mut app App) user_has_repo(user_id int, repo_name string) bool { fn (mut app App) update_repo_from_fs(mut repo Repo) ! { repo_id := repo.id - app.db.exec('BEGIN TRANSACTION') + app.db.exec('BEGIN TRANSACTION')! repo.analyse_lang(app)! @@ -242,7 +244,7 @@ fn (mut app App) update_repo_from_fs(mut repo Repo) ! { } app.save_repo(repo)! - app.db.exec('END TRANSACTION') + app.db.exec('END TRANSACTION')! app.info('Repo updated') } @@ -291,7 +293,7 @@ fn (mut app App) update_repo_from_remote(mut repo Repo) ! { repo.git('fetch --all') repo.git('pull --all') - app.db.exec('BEGIN TRANSACTION') + app.db.exec('BEGIN TRANSACTION')! repo.analyse_lang(app)! @@ -317,7 +319,7 @@ fn (mut app App) update_repo_from_remote(mut repo Repo) ! { repo.branches_count = app.get_count_repo_branches(repo_id) app.save_repo(repo)! - app.db.exec('END TRANSACTION') + app.db.exec('END TRANSACTION')! app.info('Repo updated') } @@ -580,7 +582,7 @@ fn (mut app App) cache_repository_items(mut r Repo, branch string, path string) mut dirs := []File{} // dirs first mut files := []File{} - app.db.exec('BEGIN TRANSACTION') + app.db.exec('BEGIN TRANSACTION')! for item_info in item_info_lines { 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) app.add_file(file)! } - app.db.exec('END TRANSACTION') + app.db.exec('END TRANSACTION')! return dirs } @@ -727,7 +729,7 @@ fn (mut app App) update_repo_primary_branch(repo_id int, branch string) ! { } fn (mut r Repo) clone() { - clone_result := os.execute('git clone --bare "${r.clone_url}" ${r.git_dir}') + clone_result := os.execute('git clone --bare "${r.clone_url}.git" ${r.git_dir}') close_exit_code := clone_result.exit_code if close_exit_code != 0 { diff --git a/src/user_service.v b/src/user_service.v index 0f216116..170f1311 100644 --- a/src/user_service.v +++ b/src/user_service.v @@ -250,10 +250,12 @@ pub fn (mut app App) get_all_registered_user_count() int { } fn (app App) search_users(query string) []User { - 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}%")') - mut users := []User{} + 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}%")') or { + return users + } + for row in repo_rows { users << User{ id: row.vals[0].int()