Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation errors V 0.4 #255

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion highlight/highlight.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 := ''
Expand Down
11 changes: 8 additions & 3 deletions src/feed_service.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
20 changes: 11 additions & 9 deletions src/repo_service.v
Original file line number Diff line number Diff line change
Expand Up @@ -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{} }
Expand Down Expand Up @@ -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)!

Expand All @@ -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')
}

Expand Down Expand Up @@ -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)!

Expand All @@ -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')
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions src/user_service.v
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down