DistroqueryAPI: getPackageSourceDetails: provide changelog information
This commit is contained in:
parent
3c4c996beb
commit
436a177a2e
@ -351,6 +351,26 @@ json DistroqueryAPI::getPackageSourceDetails(string repository, string package)
|
|||||||
// Children
|
// Children
|
||||||
j["children"] = getBuiltPackagesFromSourceID(ct, id);
|
j["children"] = getBuiltPackagesFromSourceID(ct, id);
|
||||||
|
|
||||||
|
// Changelog
|
||||||
|
sql = "SELECT * FROM changelog,packagers WHERE id_source=" + to_string(id) +
|
||||||
|
" AND id_packager=packagers.id";
|
||||||
|
j["changelog"] = json::array();
|
||||||
|
if (sqlite3_prepare_v2(db, sql.c_str(), sql.length(), &stmt2, NULL) == SQLITE_OK) {
|
||||||
|
while (sqlite3_step(stmt2) == SQLITE_ROW) {
|
||||||
|
json change = {};
|
||||||
|
// Convert buildtime to ISO-8601
|
||||||
|
auto itt = (time_t)sqlite3_column_int(stmt2,sqlite3_find_column_id(stmt2, NULL, "time"));
|
||||||
|
ostringstream ss;
|
||||||
|
ss << std::put_time(gmtime(&itt), "%FT%TZ");
|
||||||
|
change["date"] = ss.str();
|
||||||
|
change["packager"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, "packagers", "name")));
|
||||||
|
change["release"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "release")));
|
||||||
|
change["text"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "text")));
|
||||||
|
j["changelog"].push_back(change);
|
||||||
|
}
|
||||||
|
sqlite3_finalize(stmt2);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
j["error"] = "error preparing query '" + sql + "'";
|
j["error"] = "error preparing query '" + sql + "'";
|
||||||
return j;
|
return j;
|
||||||
|
Loading…
Reference in New Issue
Block a user