Skip to content

Commit

Permalink
[api] store explicit last issue update time
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Jan 19, 2012
1 parent 77c02dd commit 9b60fea
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/api/app/models/issue_tracker.rb
Expand Up @@ -79,10 +79,16 @@ def issue(issue_id)
end

def update_issues()
oldest_time = Issue.find( :first, :order => :updated_at).updated_at
result = bugzilla_server.search(:last_change_time => oldest_time)
update_time_stamp = Time.at(Time.now.to_f - 5)

return private_fetch_issues(ids)
result = bugzilla_server.search(:last_change_time => self.issues_updated)

ret = private_fetch_issues(ids)

self.issues_updated = update_time_stamp
self.save!

return ret
end

def fetch_issues(issues=nil)
Expand Down
5 changes: 5 additions & 0 deletions src/api/db/development_structure.sql
Expand Up @@ -311,6 +311,7 @@ CREATE TABLE `issue_trackers` (
`user` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`long_name` text NOT NULL,
`issues_updated` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Expand Down Expand Up @@ -833,6 +834,10 @@ INSERT INTO schema_migrations (version) VALUES ('20120112194300');

INSERT INTO schema_migrations (version) VALUES ('20120119194300');

INSERT INTO schema_migrations (version) VALUES ('20120119204300');

INSERT INTO schema_migrations (version) VALUES ('20120119204301');

INSERT INTO schema_migrations (version) VALUES ('21');

INSERT INTO schema_migrations (version) VALUES ('22');
Expand Down
9 changes: 9 additions & 0 deletions src/api/db/migrate/20120119204300_add_update_timestamp.rb
@@ -0,0 +1,9 @@
class AddUpdateTimestamp < ActiveRecord::Migration
def self.up
add_column :issue_trackers, :issues_updated, :integer
end

def self.down
remove_column :issue_trackers, :issues_updated
end
end
11 changes: 11 additions & 0 deletions src/api/db/migrate/20120119204301_set_current_time_as_updated.rb
@@ -0,0 +1,11 @@
class SetCurrentTimeAsUpdated < ActiveRecord::Migration
def self.up
IssueTracker.find(:all).each do |t|
t.issues_updated=Time.now unless t.issues_updated
t.save
end
end

def self.down
end
end

0 comments on commit 9b60fea

Please sign in to comment.