diff --git a/src/DistroqueryAPI.cpp b/src/DistroqueryAPI.cpp index bac2296..05b1d9a 100644 --- a/src/DistroqueryAPI.cpp +++ b/src/DistroqueryAPI.cpp @@ -351,6 +351,26 @@ json DistroqueryAPI::getPackageSourceDetails(string repository, string package) // Children 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(sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, "packagers", "name"))); + change["release"] = reinterpret_cast(sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "release"))); + change["text"] = reinterpret_cast(sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "text"))); + j["changelog"].push_back(change); + } + sqlite3_finalize(stmt2); + } + } else { j["error"] = "error preparing query '" + sql + "'"; return j;