Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

donloads: show the installer/package release date #185

Merged
merged 1 commit into from Sep 25, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/download.rb
Expand Up @@ -2,11 +2,12 @@
# t.string :filename # t.string :filename
# t.string :platform # t.string :platform
# t.references :version # t.references :version
# t.timestamp :release_date
# t.timestamps # t.timestamps
class Download < ActiveRecord::Base class Download < ActiveRecord::Base
belongs_to :version belongs_to :version


def self.latest_for(platform) def self.latest_for(platform)
includes(:version).where('platform=?', platform).order('versions.vorder DESC').order('downloads.filename DESC').first includes(:version).where('platform=?', platform).order('versions.vorder DESC').order('downloads.release_date DESC').first
end end
end end
2 changes: 1 addition & 1 deletion app/views/downloads/downloading.html.haml
Expand Up @@ -11,7 +11,7 @@
%div.callout.downloading %div.callout.downloading
%h3 Your download is starting... %h3 Your download is starting...


%p=raw "You are downloading version <strong>#{@download.version.name}</strong> of Git for the <strong>#{@platform.capitalize}</strong> platform. This is the most recent <a href='#{@project_url}'>maintained build</a> for this platform. It was released <strong>#{time_ago_in_words @download.version.committed} ago</strong>, on #{@download.version.committed.strftime("%Y-%m-%d")}." %p=raw "You are downloading version <strong>#{@download.version.name}</strong> of Git for the <strong>#{@platform.capitalize}</strong> platform. This is the most recent <a href='#{@project_url}'>maintained build</a> for this platform. It was released <strong>#{time_ago_in_words @download.release_date} ago</strong>, on #{@download.release_date.strftime("%Y-%m-%d")}."


%p=raw "<strong>If your download hasn't started, <a href=\"#{@download.url}\">click here to download manually</a>.</strong>" %p=raw "<strong>If your download hasn't started, <a href=\"#{@download.url}\">click here to download manually</a>.</strong>"


Expand Down
17 changes: 17 additions & 0 deletions db/migrate/20120925124736_add_release_date_to_downloads.rb
@@ -0,0 +1,17 @@
class AddReleaseDateToDownloads < ActiveRecord::Migration
def change
add_column :downloads, :release_date, :timestamp

Download.all.each do |d|
time = d.version.committed # best guess

if d.platform == 'windows' # for Windows, take it from the filename
d.filename =~ /Git-(.*?)-(.*?)(\d{4})(\d{2})(\d{2})\.exe/
time = Time.utc($3, $4, $5)
end

d.release_date = time
d.save
end
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.


ActiveRecord::Schema.define(:version => 20120423150252) do ActiveRecord::Schema.define(:version => 20120925124736) do


create_table "books", :force => true do |t| create_table "books", :force => true do |t|
t.string "code" t.string "code"
Expand Down Expand Up @@ -64,6 +64,7 @@
t.integer "version_id" t.integer "version_id"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.datetime "release_date"
end end


create_table "related_items", :force => true do |t| create_table "related_items", :force => true do |t|
Expand Down
4 changes: 3 additions & 1 deletion lib/tasks/downloads.rake
Expand Up @@ -5,7 +5,7 @@ task :downloads => :environment do
# find latest windows version # find latest windows version
win_downloads = Octokit.downloads("msysgit/git") win_downloads = Octokit.downloads("msysgit/git")
win_downloads.each do |down| win_downloads.each do |down|
if m = /^Git-(.*?)-(.*).exe/.match(down.name) if m = /^Git-(.*?)-(.*?)(\d{4})(\d{2})(\d{2})\.exe/.match(down.name)
version = m[1] version = m[1]
puts version = version puts version = version
puts url = down.html_url puts url = down.html_url
Expand All @@ -14,6 +14,7 @@ task :downloads => :environment do
d = v.downloads.where(:url => url).first_or_create d = v.downloads.where(:url => url).first_or_create
d.filename = down.name d.filename = down.name
d.platform = 'windows' d.platform = 'windows'
d.release_date = Time.utc(m[3], m[4], m[5])
d.save d.save
end end
end end
Expand All @@ -31,6 +32,7 @@ task :downloads => :environment do
d = v.downloads.where(:url => url).first_or_create d = v.downloads.where(:url => url).first_or_create
d.filename = down.name d.filename = down.name
d.platform = 'mac' d.platform = 'mac'
d.release_date = down.created_at
d.save d.save
end end
end end
Expand Down