Skip to content

Commit

Permalink
Improving search results when searching by commit message
Browse files Browse the repository at this point in the history
re: #431
  • Loading branch information
dlangille committed Mar 17, 2023
1 parent 6df3ee0 commit 9a9753b
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 44 deletions.
61 changes: 31 additions & 30 deletions classes/commits_by_description.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,37 @@ function ConditionSet($Condition) {
function Fetch() {
$sql = "
SELECT DISTINCT
commit_log.commit_date - SystemTimeAdjust() AS commit_date_raw,
commit_log.id AS commit_log_id,
commit_log.encoding_losses AS encoding_losses,
commit_log.message_id AS message_id,
commit_log.commit_hash_short AS commit_hash_short,
commit_log.committer AS committer,
commit_log.committer_name AS committer_name,
commit_log.committer_email AS committer_email,
commit_log.author_name AS author_name,
commit_log.author_email AS author_email,
commit_log.description AS commit_description,
to_char(commit_log.commit_date - SystemTimeAdjust(), 'DD Mon YYYY') AS commit_date,
to_char(commit_log.commit_date - SystemTimeAdjust(), 'HH24:MI') AS commit_time,
commit_log_ports.port_id AS port_id,
categories.name AS category,
categories.id AS category_id,
element.name AS port,
CASE when commit_log_ports.port_version IS NULL then ports.version else commit_log_ports.port_version END AS version,
CASE when commit_log_ports.port_version is NULL then ports.revision else commit_log_ports.port_revision END AS revision,
CASE when commit_log_ports.port_epoch is NULL then ports.portepoch else commit_log_ports.port_epoch END AS epoch,
element.status AS status,
commit_log_ports.needs_refresh AS needs_refresh,
ports.forbidden AS forbidden,
ports.broken AS broken,
ports.deprecated AS deprecated,
ports.ignore AS ignore,
ports.expiration_date AS expiration_date,
date_part('epoch', ports.date_added) AS date_added,
ports.element_id AS element_id,
ports.short_description AS short_description";
commit_log.commit_date - SystemTimeAdjust() AS commit_date_raw,
commit_log.id AS commit_log_id,
commit_log.encoding_losses AS encoding_losses,
commit_log.message_id AS message_id,
commit_log.commit_hash_short AS commit_hash_short,
commit_log.committer AS committer,
commit_log.committer_name AS committer_name,
commit_log.committer_email AS committer_email,
commit_log.author_name AS author_name,
commit_log.author_email AS author_email,
commit_log.description AS commit_description,
to_char(commit_log.commit_date - SystemTimeAdjust(), 'DD Mon YYYY') AS commit_date,
to_char(commit_log.commit_date - SystemTimeAdjust(), 'HH24:MI') AS commit_time,
commit_log_ports.port_id AS port_id,
categories.name AS category,
categories.id AS category_id,
element.name AS port,
CASE when commit_log_ports.port_version IS NULL then ports.version else commit_log_ports.port_version END AS version,
CASE when commit_log_ports.port_version is NULL then ports.revision else commit_log_ports.port_revision END AS revision,
CASE when commit_log_ports.port_epoch is NULL then ports.portepoch else commit_log_ports.port_epoch END AS epoch,
element.status AS status,
commit_log_ports.needs_refresh AS needs_refresh,
ports.forbidden AS forbidden,
ports.broken AS broken,
ports.deprecated AS deprecated,
ports.ignore AS ignore,
ports.expiration_date AS expiration_date,
date_part('epoch', ports.date_added) AS date_added,
ports.element_id AS element_id,
ports.short_description AS short_description,
null AS stf_message";
if ($this->UserID) {
$sql .= ",
onwatchlist ";
Expand Down
59 changes: 45 additions & 14 deletions www/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,19 @@ function WildCardQuery($db, $stype, $Like, $query) {
$HTML = '';

// If these items are missing from the URL, we want them to have a value
$query = '';
$stype = 'name';
$num = $User->page_size;
$category = '';
$port = '';
$method = '';
$deleted = 'excludedeleted';
$include_src_commits= INCLUDE_SRC_COMMITS;
$casesensitivity = 'caseinsensitive';
$orderby = ORDERBYCATEGORY;
$orderbyupdown = ORDERBYASCENDING;
$output_format = OUTPUT_FORMAT_HTML;
$minimal_output = 0;
$query = '';
$stype = 'name';
$num = $User->page_size;
$category = '';
$port = '';
$method = '';
$deleted = 'excludedeleted';
$include_src_commits = INCLUDE_SRC_COMMITS;
$casesensitivity = 'caseinsensitive';
$orderby = ORDERBYCATEGORY;
$orderbyupdown = ORDERBYASCENDING;
$output_format = OUTPUT_FORMAT_HTML;
$minimal_output = 0;


# No special treatment for $query. Whenever it is output: htmlentities(). Whenever it is used in a query: pg_escape_string()
Expand Down Expand Up @@ -608,6 +608,12 @@ function WildCardQuery($db, $stype, $Like, $query) {

$NumFetches = $Commits->Fetch();
$result = $Commits->LocalResult;
if ($Debug) {
if ($result) {
echo "
<br>we have a result for SEARCH_FIELD_COMMITTER<br>\n";
}
}
break;

case SEARCH_FIELD_COMMITMESSAGE:
Expand Down Expand Up @@ -646,7 +652,13 @@ function WildCardQuery($db, $stype, $Like, $query) {
$Commits->SetLimit($PageSize);

$NumFetches = $Commits->Fetch();
# $result = $Commits->LocalResult;
$result = $Commits->LocalResult;
if ($Debug) {
if ($result) {
echo "
<br>we have a result for SEARCH_FIELD_COMMITMESSAGE<br>\n";
}
}
break;

case SEARCH_FIELD_PATHNAME:
Expand Down Expand Up @@ -703,6 +715,13 @@ function WildCardQuery($db, $stype, $Like, $query) {
$NumFetches = $Commits->Fetch();
}
$result = $Commits->LocalResult;
if ($Debug) {
if ($result) {
echo "
<br>we have a result for SEARCH_FIELD_PATHNAME<br>\n";
}
}

break;

case SEARCH_FIELD_PKG_PLIST:
Expand Down Expand Up @@ -766,6 +785,12 @@ function WildCardQuery($db, $stype, $Like, $query) {

# $result get used later on to display the search results via classes/port-display.php
$result = $Ports->LocalResult;
if ($Debug) {
if ($result) {
echo "
<br>we have a result for SEARCH_FIELD_USES<br>\n";
}
}
break;


Expand Down Expand Up @@ -874,6 +899,12 @@ function WildCardQuery($db, $stype, $Like, $query) {
}

$NumFetches = pg_num_rows($result);
if ($Debug) {
if ($result) {
echo "
<br>we have a result for 'default'<br>\n";
}
}
} # $NumFound > 0

} // end of non-committer search ## I think this is the end of the default option
Expand Down

0 comments on commit 9a9753b

Please sign in to comment.