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 DistroqueryAPI::getPackageDetails(string repository, string package, string arch) {
|
||||||
json j;
|
json j;
|
||||||
string sql;
|
string sql;
|
||||||
sqlite3_stmt *stmt, *stmt2;
|
sqlite3_stmt *stmt, *stmt2, *stmt3;
|
||||||
|
|
||||||
struct configTag* ct = findRepositoryByTag(repository.c_str());
|
struct configTag* ct = findRepositoryByTag(repository.c_str());
|
||||||
if (ct == NULL) {
|
if (ct == NULL) {
|
||||||
@ -194,15 +194,28 @@ json DistroqueryAPI::getPackageDetails(string repository, string package, string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Requires
|
// Requires
|
||||||
sql = "SELECT * FROM requires,provided WHERE requires.id_package=" + to_string(id) +
|
sql = "SELECT * FROM requires,provided WHERE requires.id_package=" + to_string(id) +
|
||||||
" AND provided.id=requires.id_provided ORDER BY provided.name";
|
" AND provided.id=requires.id_provided ORDER BY provided.name";
|
||||||
j["requires"] = json::array();
|
j["requires"] = json::array();
|
||||||
if (sqlite3_prepare_v2(db, sql.c_str(), sql.length(), &stmt2, NULL) == SQLITE_OK) {
|
if (sqlite3_prepare_v2(db, sql.c_str(), sql.length(), &stmt2, NULL) == SQLITE_OK) {
|
||||||
while (sqlite3_step(stmt2) == SQLITE_ROW) {
|
while (sqlite3_step(stmt2) == SQLITE_ROW) {
|
||||||
json require = {};
|
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["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["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["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);
|
j["requires"].push_back(require);
|
||||||
}
|
}
|
||||||
sqlite3_finalize(stmt2);
|
sqlite3_finalize(stmt2);
|
||||||
|
Loading…
Reference in New Issue
Block a user