Skip to content

Commit

Permalink
Introduced Etag/Last-mod/Reval support to project indexes. See JILS-41
Browse files Browse the repository at this point in the history
  • Loading branch information
bentasker committed Apr 22, 2016
1 parent b2c15d7 commit b249ebf
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions project-index.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,34 @@
die;
}

// Introduced in JILS-41
$sql = "SELECT MAX(cg.CREATED) as lastupdate ".
"FROM jiraissue AS a ".
"LEFT JOIN project AS b on a.PROJECT = b.ID ".
"LEFT JOIN changegroup AS cg ON a.ID = cg.issueid " .
"LEFT JOIN changeitem AS ci ON cg.ID = ci.groupid " .
"WHERE b.pkey='".$db->stringEscape($_GET['proj'])."'";

$db->setQuery($sql);
$lastchange = $db->loadResult();
$lchange=strtotime($lastchange->lastupdate);
$dstring=gmdate('D, d M Y H:i:s T',$lchange);

// Take changes to the project record itself into account. Could do with being able to do that with Last-Mod, but haven't seen a way yet
$etag="prj-".$_GET['proj']."-".sha1("lc:$lchange;v:".json_encode($project));

header("Last-Modified: $dstring");
header("E-Tag: $etag");

// Introduced in JILS-41
evaluateConditionalRequest($dstring,$etag);

if (stripos($_SERVER['REQUEST_METHOD'], 'HEAD') !== FALSE) {
exit();
}



// Get details of timespent
$db->setQuery("SELECT SUM(TIMESPENT) as TIMESPENT, SUM(TIMEORIGINALESTIMATE) as estimate FROM jiraissue where PROJECT=".(int)$project->ID);
$time = $db->loadResult();
Expand Down

0 comments on commit b249ebf

Please sign in to comment.