Compare commits

..

No commits in common. "ec8b4088c000705f6e5eb92a89cea18ce4914e7a" and "f320087f124e437565dc69de4f43d2528fd75ca6" have entirely different histories.

5 changed files with 6 additions and 30 deletions

View File

@ -137,31 +137,15 @@ json DistroqueryAPI::getRepositoryPackages(string repository, int per_page, int
return j;
}
for (auto arch: ct->arch) {
if (arch == NULL) break;
attachRepositoryDatabases(ct, db, arch, 0);
}
string query_append;
if (query != "")
query_append = "WHERE name LIKE '%" + query + "%' OR summary LIKE '%" + query +
"%' OR description LIKE '%" + query + "%'";
sql = "SELECT u.*,COUNT(*) OVER() AS total_count FROM ("
"SELECT name,arch,version,release,summary,buildtime,0 AS sort FROM sources " + query_append;
int archorder = 1;
for (auto arch: ct->arch) {
if (arch == NULL) break;
sql += " UNION SELECT name,arch,version,release,summary,buildtime," + to_string(archorder) +
" AS sort FROM '" + repository + "_" + arch + "'.packages " + query_append;
archorder++;
}
sql += ") AS u ORDER BY name COLLATE NOCASE ASC,sort"
sql = "SELECT COUNT(*) OVER() AS total_count,* FROM sources " + query_append +
" ORDER BY name COLLATE NOCASE ASC"
" LIMIT " + to_string(per_page) +
" OFFSET " + to_string(per_page * (page -1));
if (sqlite3_prepare_v2(db, sql.c_str(), sql.length(), &stmt, NULL) == SQLITE_OK) {
json packages = json::array();
long count = 0;
@ -176,7 +160,6 @@ json DistroqueryAPI::getRepositoryPackages(string repository, int per_page, int
}
json package;
package["name"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt,sqlite3_find_column_id(stmt, NULL, "name")));
package["arch"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt,sqlite3_find_column_id(stmt, NULL, "arch")));
package["version"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt,sqlite3_find_column_id(stmt, NULL, "version")));
package["release"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt,sqlite3_find_column_id(stmt, NULL, "release")));
package["summary"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt,sqlite3_find_column_id(stmt, NULL, "summary")));
@ -190,7 +173,7 @@ json DistroqueryAPI::getRepositoryPackages(string repository, int per_page, int
j["query"]["to"] = per_page * (page - 1) + count;
j["packages"] = packages;
} else {
j["error"] = "error preparing query '" + sql + "': " + sqlite3_errmsg(db);
j["error"] = "error preparing query '" + sql + "'";
return j;
}
return j;

View File

@ -317,7 +317,7 @@ long generateSQLite_add_changelog(sqlite3 *db, struct changeLog* firstchangelog,
#define SQLITE_TABLE_packages "id INTEGER PRIMARY KEY, "\
"name STRING, arch STRING, altrepository INTEGER, epoch INTEGER, version STRING, release STRING, summary STRING, "\
"groupdescr STRING, description STRING, buildtime INTEGER, size INTEGER, id_source INTEGER"
"groupdescr STRING, description STRING, size INTEGER, id_source INTEGER"
#define SQLITE_TABLE_obsoletes "id INTEGER PRIMARY KEY, "\
"id_package INTEGER, obsoletename STRING, obsoleteflags INTEGER, obsoleteversion STRING"
@ -343,10 +343,9 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
currpackage = ct->headerlist[arch];
while (currpackage) {
if (currpackage->altrepository == ct->repository_level) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages VALUES(NULL,?,?,%d,%ld,?,?,?,?,?,%ld,%ld,%ld);",
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages VALUES(NULL,?,?,%d,%ld,?,?,?,?,?,%ld,%ld);",
currpackage->altrepository,
currpackage->epoch,
currpackage->buildtime,
currpackage->size,
currpackage->sourceheader->id);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {

View File

@ -97,7 +97,7 @@ void attachRepositoryDatabases(struct configTag* ct, sqlite3 *db, string arch, i
char *errmsg;
dbname = string(ct->repository_dir) + ct->tag + "-" + arch + ".db";
sql = "ATTACH DATABASE '" + dbname + "' as '" + ct->tag + "_" + arch + "'";
sql = "ATTACH DATABASE '" + dbname + "' as '" + ct->tag + "_" + arch;
if (sqlite3_exec(db, sql.c_str(), NULL, NULL, &errmsg)) {
cerr << "ERROR: unable to exec statement for " << sql << ": " << errmsg << endl;
}

View File

@ -171,7 +171,6 @@ getPackageInfoIntoHeaderList(Header h, struct headerList *hl)
hl->description = headerGetStringEntry(h, RPMTAG_DESCRIPTION);
hl->sourcename = headerGetStringEntry(h, RPMTAG_SOURCERPM);
hl->group = headerGetStringEntry(h, RPMTAG_GROUP);
hl->buildtime = headerGetUIntEntry(h, RPMTAG_BUILDTIME);
hl->size = headerGetUIntEntry(h, RPMTAG_SIZE);
return 0;
@ -1634,10 +1633,6 @@ char* advanceXMLPackageNode(xmlNode **primary_node, xmlNode **filelists_node) {
findXMLPropertyByName(format, "group")->children->content);
newheaderlist->sourcename = strdup((char*)
findXMLPropertyByName(format, "sourcerpm")->children->content);
xmlNode *ptime = findXMLPropertyByName(primary_node[altidx], "time");
tmp = (char*)findXMLAttributeByName(ptime, "build");
newheaderlist->buildtime = atoi(tmp);
free(tmp);
xmlNode *psize = findXMLPropertyByName(primary_node[altidx], "size");
tmp = (char*)findXMLAttributeByName(psize, "package");
newheaderlist->size = atoi(tmp);

View File

@ -79,7 +79,6 @@ struct headerList {
char *description;
char *sourcename;
char *arch;
long buildtime;
long size;
char **obsoletename;
uint_32 *obsoleteflags;