distroquey: results order by relevance and some more improvements

This commit is contained in:
Silvan Calarco 2013-10-09 13:24:10 +02:00
parent fb4d8d65a6
commit 7289d581c2

View File

@ -154,13 +154,13 @@ void printInputForm() {
ct = ct->next; ct = ct->next;
} }
printf("</select>");*/ printf("</select>");*/
printf("<input type=checkbox id=\"search_devel\" checked=checked>devel&nbsp;"); printf("<input type=checkbox id=\"search_devel\" checked=checked onclick=%s>devel&nbsp;", ajax_call);
printf("<input type=checkbox id=\"search_milestone2\" checked=checked>milestone2&nbsp;"); printf("<input type=checkbox id=\"search_milestone2\" checked=checked onclick=%s>milestone2&nbsp;", ajax_call);
printf("<input type=checkbox id=\"search_milestone1\">milestone1&nbsp;"); printf("<input type=checkbox id=\"search_milestone1\" onclick=%s>milestone1&nbsp;", ajax_call);
printf("&nbsp;<input type=checkbox id=\"search_i586\" checked=checked>i586&nbsp;"); printf("&nbsp;<input type=checkbox id=\"search_i586\" checked=checked onclick=%s>i586&nbsp;", ajax_call);
printf("<input type=checkbox id=\"search_x86_64\">x86_64&nbsp;"); printf("<input type=checkbox id=\"search_x86_64\" onclick=%s>x86_64&nbsp;", ajax_call);
printf("<input type=checkbox id=\"search_arm\">arm&nbsp;"); printf("<input type=checkbox id=\"search_arm\" onclick=%s>arm&nbsp;", ajax_call);
printf("<input type=checkbox id=\"search_sources\">sources&nbsp;"); printf("<input type=checkbox id=\"search_sources\" onclick=%s>sources&nbsp;", ajax_call);
printf("<br>"); printf("<br>");
/* ct = firstconfigtag; /* ct = firstconfigtag;
while (ct) { while (ct) {
@ -196,13 +196,16 @@ void printQueryData() {
if ((search_i586 && !strcmp(query_repositories[i]->arch[a],"i586")) || if ((search_i586 && !strcmp(query_repositories[i]->arch[a],"i586")) ||
(search_arm && !strcmp(query_repositories[i]->arch[a],"arm")) || (search_arm && !strcmp(query_repositories[i]->arch[a],"arm")) ||
(search_x86_64 && !strcmp(query_repositories[i]->arch[a],"x86_64"))) { (search_x86_64 && !strcmp(query_repositories[i]->arch[a],"x86_64"))) {
snprintf(sql, PATH_MAX, "SELECT * FROM packages_%s WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%'", query_repositories[i]->arch[a], query, query, query); snprintf(sql, PATH_MAX,
"SELECT * FROM packages_%s WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%' "
"ORDER BY name = '%s' DESC, name LIKE '%s%%' DESC, name LIKE '%%%s%%' DESC",
query_repositories[i]->arch[a], query, query, query, query, query, query);
if (query_repositories[i]->db && if (query_repositories[i]->db &&
(sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) { (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
while (sqlite3_step(statement) == SQLITE_ROW) { while (sqlite3_step(statement) == SQLITE_ROW) {
numresults++; numresults++;
printf("<div style='position:relative'><hr><br><div style='display:inline;color:white;background-color:green'> %s </div>&nbsp;" printf("<div style='position:relative'><hr><br><div style='display:inline;color:white;background-color:green'>&nbsp;%s&nbsp;</div>&nbsp;"
"<div style='display:inline;color:black;background-color:yellow'> %s </div><br>" "<div style='display:inline;color:black;background-color:yellow'>&nbsp;%s&nbsp;</div><br>"
"<b>%s</b> %s-%s<br>%s<br>Group: %s", "<b>%s</b> %s-%s<br>%s<br>Group: %s",
query_repositories[i]->arch[a], query_repositories[i]->arch[a],
query_repositories[i]->tag, query_repositories[i]->tag,
@ -216,26 +219,26 @@ void printQueryData() {
sqlite3_column_text(statement,8)); sqlite3_column_text(statement,8));
/* install */ /* install */
printf("<div align=right style='position:absolute;top:5px;right:0;padding:5px;'>" /* printf("<div align=right style='position:absolute;top:5px;right:0;padding:5px;'>"
"<div><object type=\"application/x-packagekit-plugin\" width=\"400\" height=\"50\">" "<div><object type=\"application/x-packagekit-plugin\" width=\"400\" height=\"50\">"
"<param name=\"displayname\" value=\"%s - %s\" />" "<param name=\"displayname\" value=\"%s - %s\" />"
"<param name=\"packagenames\" value=\"%s\" /></object></div>", "<param name=\"packagenames\" value=\"%s\" /></object></div>",
sqlite3_column_text(statement,1), sqlite3_column_text(statement,1),
sqlite3_column_text(statement,6), sqlite3_column_text(statement,6),
sqlite3_column_text(statement,1)); sqlite3_column_text(statement,1));*/
/* download */ /* download */
printf("<div style='display:inline;color:white;background-color:green;font-weight:strong'>" printf("<div style='display:inline;background-color:green'>"
"<a href=\"%s%s/SRPMS.base/%s-%s-%s.src.rpm\"> Download </a></div>", "<a href=\"%s%s/SRPMS.base/%s-%s-%s.src.rpm\" style=\"color:white\">&nbsp;Download&nbsp;</a></div>",
query_repositories[i]->download_prefix, query_repositories[i]->download_prefix,
query_repositories[i]->download_dir, query_repositories[i]->download_dir,
sqlite3_column_text(statement,1), sqlite3_column_text(statement,1),
sqlite3_column_text(statement,4), sqlite3_column_text(statement,4),
sqlite3_column_text(statement,5)); sqlite3_column_text(statement,5));
/* details */ /* details */
printf("<div style='display:inline;background-color:lightblue;font-weight:strong'>" printf("&nbsp;<div style='display:inline;background-color:lightblue;font-weight:strong'>"
"<a href='javascript:distroquery_request(" "<a href='javascript:distroquery_request("
"\"repository=%s&package=%s&arch=%s\")'> Details </a></div>", "\"repository=%s&package=%s&arch=%s\")' style=\"color:black\">&nbsp;Details&nbsp;</a></div>",
query_repositories[i]->tag, query_repositories[i]->tag,
sqlite3_column_text(statement,1), sqlite3_column_text(statement,1),
query_repositories[i]->arch[a]); query_repositories[i]->arch[a]);
@ -249,14 +252,17 @@ void printQueryData() {
} }
if (search_sources) { if (search_sources) {
snprintf(sql, PATH_MAX, "SELECT * FROM sources WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%'", query, query, query); snprintf(sql, PATH_MAX,
"SELECT * FROM sources WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%' "
"ORDER BY name = '%s' DESC, name LIKE '%s%%' DESC, name LIKE '%%%s%%' DESC",
query, query, query, query, query, query);
for (i = 0; query_repositories[i] != NULL; i++) { for (i = 0; query_repositories[i] != NULL; i++) {
if (query_repositories[i]->db && if (query_repositories[i]->db &&
(sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) { (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
while (sqlite3_step(statement) == SQLITE_ROW) { while (sqlite3_step(statement) == SQLITE_ROW) {
numresults++; numresults++;
printf("<hr><br><div style='display:inline;color:black;background-color:red'> Source </div>&nbsp;" printf("<hr><br><div style='display:inline;color:black;background-color:red'>&nbsp;Source&nbsp;</div>&nbsp;"
"<div style='display:inline;color:black;background-color:yellow'> %s </div><br>" "<div style='display:inline;color:black;background-color:yellow'>&nbsp;%s&nbsp;</div><br>"
"<b>%s</b> %s-%s<br>%s<br>Group: %s<br>License: %s</br>URL: %s<br><br>" "<b>%s</b> %s-%s<br>%s<br>Group: %s<br>License: %s</br>URL: %s<br><br>"
"<div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div><br>", "<div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div><br>",
query_repositories[i]->tag, query_repositories[i]->tag,
@ -392,10 +398,18 @@ void parse_request_variables(char *data) {
ct = firstconfigtag; ct = firstconfigtag;
i = 0; i = 0;
while (ct) {
if ((strstr(ct->tag, "devel") == ct->tag) && search_devel) query_repositories[i++] = ct;
ct = ct->next;
}
ct = firstconfigtag;
while (ct) {
if ((strstr(ct->tag, "milestone2") == ct->tag) && search_milestone2) query_repositories[i++] = ct;
ct = ct->next;
}
ct = firstconfigtag;
while (ct) { while (ct) {
if ((strstr(ct->tag, "milestone1") == ct->tag) && search_milestone1) query_repositories[i++] = ct; if ((strstr(ct->tag, "milestone1") == ct->tag) && search_milestone1) query_repositories[i++] = ct;
else if ((strstr(ct->tag, "milestone2") == ct->tag) && search_milestone2) query_repositories[i++] = ct;
else if ((strstr(ct->tag, "devel") == ct->tag) && search_devel) query_repositories[i++] = ct;
ct = ct->next; ct = ct->next;
} }
query_repositories[i++] = NULL; query_repositories[i++] = NULL;