mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +00:00
additional fixes for #79: chunked http log
use correct sqlite column name remove redundant code, tidy implementation
This commit is contained in:
parent
cec4721e52
commit
807901c719
@ -126,7 +126,7 @@ uint Laminar::latestRun(std::string job) {
|
||||
auto it = activeJobs.byJobName().equal_range(job);
|
||||
if(it.first == it.second) {
|
||||
uint result = 0;
|
||||
db->stmt("SELECT MAX(buildNum) FROM builds WHERE name = ?")
|
||||
db->stmt("SELECT MAX(number) FROM builds WHERE name = ?")
|
||||
.bind(job)
|
||||
.fetch<uint>([&](uint x){
|
||||
result = x;
|
||||
@ -145,8 +145,7 @@ bool Laminar::handleLogRequest(std::string name, uint num, std::string& output,
|
||||
complete = false;
|
||||
return true;
|
||||
} else { // it must be finished, fetch it from the database
|
||||
const char* stmt = num == 0 ? "SELECT output, outputLen FROM builds WHERE name = ? ORDER BY number DESC LIMIT 1" : "SELECT output, outputLen FROM builds WHERE name = ? AND number = ?" ;
|
||||
db->stmt(stmt)
|
||||
db->stmt("SELECT output, outputLen FROM builds WHERE name = ? AND number = ?")
|
||||
.bind(name, num)
|
||||
.fetch<str,int>([&](str maybeZipped, unsigned long sz) {
|
||||
str log(sz,'\0');
|
||||
|
@ -356,10 +356,11 @@ private:
|
||||
name = path.slice(0, *sep).begin();
|
||||
kj::StringPtr tail = path.slice(*sep+1);
|
||||
num = static_cast<uint>(atoi(tail.begin()));
|
||||
if(num > 0 || tail == "latest") {
|
||||
name.erase(*sep);
|
||||
name.erase(*sep);
|
||||
if(tail == "latest")
|
||||
num = laminar.latestRun(name);
|
||||
if(num > 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -407,8 +408,6 @@ private:
|
||||
} else if(parseLogEndpoint(url, name, num)) {
|
||||
kj::Own<HttpChunkedClient> cc = kj::heap<HttpChunkedClient>(laminar);
|
||||
cc->scope.job = name;
|
||||
if(num == 0)
|
||||
num = laminar.latestRun(name);
|
||||
cc->scope.num = num;
|
||||
bool complete;
|
||||
std::string output;
|
||||
|
Loading…
Reference in New Issue
Block a user