forked from vieter-v/vieter
Removed old commented code
parent
0a6c0b4c05
commit
5ab60c637b
|
|
@ -121,18 +121,12 @@ pub fn (db &VieterDb) update_git_repo(repo_id int, params map[string]string) {
|
||||||
// Any fields that are array types require their own update method
|
// Any fields that are array types require their own update method
|
||||||
$if field.typ is string {
|
$if field.typ is string {
|
||||||
values << "$field.name = '${params[field.name]}'"
|
values << "$field.name = '${params[field.name]}'"
|
||||||
// r.$(field.name) = params[field.name]
|
|
||||||
// This specific type check is needed for the compiler to ensure
|
|
||||||
// our types are correct
|
|
||||||
}
|
}
|
||||||
//$else $if field.typ is []GitRepoArch {
|
|
||||||
// r.$(field.name) = params[field.name].split(',').map(GitRepoArch{ value: it })
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
values_str := values.join(', ')
|
values_str := values.join(', ')
|
||||||
query := 'update GitRepo set $values_str where id == $repo_id'
|
query := 'update GitRepo set $values_str where id == $repo_id'
|
||||||
println(query)
|
|
||||||
db.conn.exec_none(query)
|
db.conn.exec_none(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ module git
|
||||||
import cli
|
import cli
|
||||||
import env
|
import env
|
||||||
import cron.expression { parse_expression }
|
import cron.expression { parse_expression }
|
||||||
import db
|
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
address string [required]
|
address string [required]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
module server
|
module server
|
||||||
|
|
||||||
import web
|
import web
|
||||||
import git
|
|
||||||
import net.http
|
import net.http
|
||||||
import rand
|
|
||||||
import response { new_data_response, new_response }
|
import response { new_data_response, new_response }
|
||||||
import db
|
import db
|
||||||
|
|
||||||
|
|
@ -17,13 +15,6 @@ fn (mut app App) get_repos() web.Result {
|
||||||
}
|
}
|
||||||
|
|
||||||
repos := app.db.get_git_repos()
|
repos := app.db.get_git_repos()
|
||||||
// repos := rlock app.git_mutex {
|
|
||||||
// git.read_repos(app.conf.repos_file) or {
|
|
||||||
// app.lerror('Failed to read repos file: $err.msg()')
|
|
||||||
|
|
||||||
// return app.status(http.Status.internal_server_error)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
return app.json(http.Status.ok, new_data_response(repos))
|
return app.json(http.Status.ok, new_data_response(repos))
|
||||||
}
|
}
|
||||||
|
|
@ -35,19 +26,6 @@ fn (mut app App) get_single_repo(id int) web.Result {
|
||||||
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
||||||
}
|
}
|
||||||
|
|
||||||
// repos := rlock app.git_mutex {
|
|
||||||
// git.read_repos(app.conf.repos_file) or {
|
|
||||||
// app.lerror('Failed to read repos file.')
|
|
||||||
|
|
||||||
// return app.status(http.Status.internal_server_error)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// if id !in repos {
|
|
||||||
// return app.not_found()
|
|
||||||
//}
|
|
||||||
|
|
||||||
// repo := repos[id]
|
|
||||||
repo := app.db.get_git_repo(id) or { return app.not_found() }
|
repo := app.db.get_git_repo(id) or { return app.not_found() }
|
||||||
|
|
||||||
return app.json(http.Status.ok, new_data_response(repo))
|
return app.json(http.Status.ok, new_data_response(repo))
|
||||||
|
|
@ -74,32 +52,6 @@ fn (mut app App) post_repo() web.Result {
|
||||||
|
|
||||||
app.db.add_git_repo(new_repo)
|
app.db.add_git_repo(new_repo)
|
||||||
|
|
||||||
// id := rand.uuid_v4()
|
|
||||||
|
|
||||||
// mut repos := rlock app.git_mutex {
|
|
||||||
// git.read_repos(app.conf.repos_file) or {
|
|
||||||
// app.lerror('Failed to read repos file.')
|
|
||||||
|
|
||||||
// return app.status(http.Status.internal_server_error)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
// repos := app.db.get_git_repos()
|
|
||||||
|
|
||||||
//// We need to check for duplicates
|
|
||||||
// for _, repo in repos {
|
|
||||||
// if repo == new_repo {
|
|
||||||
// return app.json(http.Status.bad_request, new_response('Duplicate repository.'))
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// repos[id] = new_repo
|
|
||||||
|
|
||||||
// lock app.git_mutex {
|
|
||||||
// git.write_repos(app.conf.repos_file, &repos) or {
|
|
||||||
// return app.status(http.Status.internal_server_error)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
return app.json(http.Status.ok, new_response('Repo added successfully.'))
|
return app.json(http.Status.ok, new_response('Repo added successfully.'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,25 +62,9 @@ fn (mut app App) delete_repo(id int) web.Result {
|
||||||
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
return app.json(http.Status.unauthorized, new_response('Unauthorized.'))
|
||||||
}
|
}
|
||||||
|
|
||||||
// mut repos := rlock app.git_mutex {
|
|
||||||
// git.read_repos(app.conf.repos_file) or {
|
|
||||||
// app.lerror('Failed to read repos file.')
|
|
||||||
|
|
||||||
// return app.status(http.Status.internal_server_error)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// if id !in repos {
|
|
||||||
// return app.not_found()
|
|
||||||
//}
|
|
||||||
|
|
||||||
// repos.delete(id)
|
// repos.delete(id)
|
||||||
app.db.delete_git_repo(id)
|
app.db.delete_git_repo(id)
|
||||||
|
|
||||||
// lock app.git_mutex {
|
|
||||||
// git.write_repos(app.conf.repos_file, &repos) or { return app.server_error(500) }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return app.json(http.Status.ok, new_response('Repo removed successfully.'))
|
return app.json(http.Status.ok, new_response('Repo removed successfully.'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,23 +83,5 @@ fn (mut app App) patch_repo(id int) web.Result {
|
||||||
app.db.update_git_repo_archs(id, arch_objs)
|
app.db.update_git_repo_archs(id, arch_objs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// mut repos := rlock app.git_mutex {
|
|
||||||
// git.read_repos(app.conf.repos_file) or {
|
|
||||||
// app.lerror('Failed to read repos file.')
|
|
||||||
|
|
||||||
// return app.status(http.Status.internal_server_error)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if id !in repos {
|
|
||||||
// return app.not_found()
|
|
||||||
// }
|
|
||||||
|
|
||||||
// repos[id].patch_from_params(app.query)
|
|
||||||
|
|
||||||
// lock app.git_mutex {
|
|
||||||
// git.write_repos(app.conf.repos_file, &repos) or { return app.server_error(500) }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return app.json(http.Status.ok, new_response('Repo updated successfully.'))
|
return app.json(http.Status.ok, new_response('Repo updated successfully.'))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue