DistroqueryAPI: getPackageDetails: add providers for requires
This commit is contained in:
parent
1f0dcb118f
commit
457f455bf3
@ -108,7 +108,7 @@ json DistroqueryAPI::getPackageSourceDetailsById(string repository, long id) {
|
||||
json DistroqueryAPI::getPackageDetails(string repository, string package, string arch) {
|
||||
json j;
|
||||
string sql;
|
||||
sqlite3_stmt *stmt, *stmt2;
|
||||
sqlite3_stmt *stmt, *stmt2, *stmt3;
|
||||
|
||||
struct configTag* ct = findRepositoryByTag(repository.c_str());
|
||||
if (ct == NULL) {
|
||||
@ -200,9 +200,22 @@ json DistroqueryAPI::getPackageDetails(string repository, string package, string
|
||||
if (sqlite3_prepare_v2(db, sql.c_str(), sql.length(), &stmt2, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt2) == SQLITE_ROW) {
|
||||
json require = {};
|
||||
long id_provided = sqlite3_column_int(stmt2,sqlite3_find_column_id(stmt2, NULL, "id_provided"));
|
||||
require["name"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "name")));
|
||||
require["flags"] = rpmSenseFlagsToString(sqlite3_column_int(stmt2,sqlite3_find_column_id(stmt2, NULL, "requireflags")));
|
||||
require["version"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "requireversion")));
|
||||
require["providers"] = json::array();
|
||||
sql = "SELECT * FROM provides,packages WHERE id_provided=" + to_string(id_provided) +
|
||||
" AND packages.id=provides.id_package";
|
||||
if (sqlite3_prepare_v2(db, sql.c_str(), sql.length(), &stmt3, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt3) == SQLITE_ROW) {
|
||||
json provider = {};
|
||||
provider["name"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt3,sqlite3_find_column_id(stmt3, NULL, "name")));
|
||||
provider["altrepository"] = sqlite3_column_int(stmt3,sqlite3_find_column_id(stmt3, NULL, "altrepostory"));
|
||||
require["providers"].push_back(provider);
|
||||
}
|
||||
sqlite3_finalize(stmt3);
|
||||
}
|
||||
j["requires"].push_back(require);
|
||||
}
|
||||
sqlite3_finalize(stmt2);
|
||||
|
Loading…
Reference in New Issue
Block a user