Skip to content

Commit

Permalink
show last checked time on resource page
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui Yang committed Dec 27, 2017
1 parent a83232a commit f5ec786
Show file tree
Hide file tree
Showing 8 changed files with 778 additions and 515 deletions.
68 changes: 57 additions & 11 deletions db/migration/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
BEGIN;
ALTER TABLE build_inputs
ALTER COLUMN modified_time TYPE timestamp without time zone;

ALTER TABLE build_outputs
ALTER COLUMN modified_time TYPE timestamp without time zone;

ALTER TABLE cache_invalidator
ALTER COLUMN last_invalidated TYPE timestamp without time zone;
ALTER TABLE cache_invalidator
ALTER COLUMN last_invalidated SET DEFAULT '1970-01-01 00:00:00'::timestamp without time zone;

ALTER TABLE containers
ALTER COLUMN best_if_used_by TYPE timestamp without time zone;

ALTER TABLE pipelines
ALTER COLUMN last_scheduled TYPE timestamp without time zone;
ALTER TABLE pipelines
ALTER COLUMN last_scheduled SET DEFAULT '1970-01-01 00:00:00'::timestamp without time zone;

ALTER TABLE resource_types
ALTER COLUMN last_checked TYPE timestamp without time zone;
ALTER TABLE resource_types
ALTER COLUMN last_checked SET DEFAULT '1970-01-01 00:00:00'::timestamp without time zone;

ALTER TABLE resources
ALTER COLUMN last_checked TYPE timestamp without time zone;
ALTER TABLE resources
ALTER COLUMN last_checked SET DEFAULT '1970-01-01 00:00:00'::timestamp without time zone;

ALTER TABLE versioned_resources
ALTER COLUMN modified_time TYPE timestamp without time zone;
COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
BEGIN;
ALTER TABLE build_inputs
ALTER COLUMN modified_time TYPE timestamp with time zone;

ALTER TABLE build_outputs
ALTER COLUMN modified_time TYPE timestamp with time zone;

ALTER TABLE cache_invalidator
ALTER COLUMN last_invalidated TYPE timestamp with time zone;
ALTER TABLE cache_invalidator
ALTER COLUMN last_invalidated SET DEFAULT '1970-01-01 00:00:00'::timestamp with time zone;

ALTER TABLE containers
ALTER COLUMN best_if_used_by TYPE timestamp with time zone;

ALTER TABLE pipelines
ALTER COLUMN last_scheduled TYPE timestamp with time zone;
ALTER TABLE pipelines
ALTER COLUMN last_scheduled SET DEFAULT '1970-01-01 00:00:00'::timestamp with time zone;

ALTER TABLE resource_types
ALTER COLUMN last_checked TYPE timestamp with time zone;
ALTER TABLE resource_types
ALTER COLUMN last_checked SET DEFAULT '1970-01-01 00:00:00'::timestamp with time zone;

ALTER TABLE resources
ALTER COLUMN last_checked TYPE timestamp with time zone;
ALTER TABLE resources
ALTER COLUMN last_checked DROP DEFAULT;
ALTER TABLE resources
ALTER COLUMN last_checked DROP NOT NULL;

ALTER TABLE versioned_resources
ALTER COLUMN modified_time TYPE timestamp with time zone;
COMMIT;

2 changes: 1 addition & 1 deletion db/pipeline_locks.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (p *pipeline) checkIfResourceIntervalUpdated(

condition := ""
if !immediate {
condition = "AND now() - last_checked > ($3 || ' SECONDS')::INTERVAL"
condition = "AND (now() - last_checked > ($3 || ' SECONDS')::INTERVAL OR last_checked IS NULL)"
params = append(params, interval.Seconds())
}

Expand Down
6 changes: 5 additions & 1 deletion db/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

sq "github.com/Masterminds/squirrel"
"github.com/concourse/atc"
"github.com/lib/pq"
)

//go:generate counterfeiter . Resource
Expand Down Expand Up @@ -168,13 +169,16 @@ func scanResource(r *resource, row scannable) error {
var (
configBlob []byte
checkErr, nonce sql.NullString
lastChecked pq.NullTime
)

err := row.Scan(&r.id, &r.name, &configBlob, &checkErr, &r.paused, &r.lastChecked, &r.pipelineID, &r.pipelineName, &nonce)
err := row.Scan(&r.id, &r.name, &configBlob, &checkErr, &r.paused, &lastChecked, &r.pipelineID, &r.pipelineName, &nonce)
if err != nil {
return err
}

r.lastChecked = lastChecked.Time

es := r.conn.EncryptionStrategy()

var noncense *string
Expand Down
5 changes: 5 additions & 0 deletions web/assets/css/production.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
margin: 6px 0px 6px 24px;
}

.pagination-header .last-checked {
float: left;
margin-left: 24px;
}

.build-action {
background: transparent;
border: none;
Expand Down
Loading

0 comments on commit f5ec786

Please sign in to comment.