This repository has been archived by the owner on Jul 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add delete feature to announcements Add gpl3 license Store user IP addresses for submitted quotes Database migration for original PHP Rash -> Rash on Rails Don't add unnecessary seeds in production
- Loading branch information
Showing
15 changed files
with
805 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<strong><%= announcement.created_at.strftime("%Y.%m.%d %H:%M:%S %Z") %></strong> | ||
<strong><%= announcement.created_at.strftime("%Y.%m.%d %H:%M:%S %Z") %></strong> <% if user_signed_in? %><%= link_to 'Delete', announcement, method: :delete, data: { confirm: 'Are you sure you want to delete this announcement?' } %><% end %> | ||
|
||
<pre> | ||
<%= announcement.text %> | ||
</pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddSubmitteripToQuotes < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column :quotes, :submitterip, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
namespace :legacy do | ||
desc 'Migrate data from RQMS legacy (Beta 2.0) database and copy to current environment' | ||
task migrate_database: :environment do | ||
require 'mysql2' | ||
require 'optparse' | ||
|
||
options = {'tableprefix': 'rash'} | ||
|
||
o = OptionParser.new do |opts| | ||
opts.banner = 'Usage: rake legacy:migrate_database [options]' | ||
opts.on('-h HOST', '--host HOST') { |host| options['host'] = host } | ||
opts.on('-s SOCKET', '--socket SOCKET') { |socket| options['socket'] = socket } | ||
opts.on('-d DATABASE', '--database DATABASE') { |database| options['database'] = database } | ||
opts.on('-u USERNAME', '--username USERNAME') { |username| options['username'] = username } | ||
opts.on('-p PASSWORD', '--password PASSWORD') { |password| options['password'] = password } | ||
opts.on('-t TABLEPREFIX', '--tableprefix TABLEPREFIX') { |tableprefix| options['tableprefix'] = tableprefix } | ||
opts.on_tail('--help', 'Show this message') do | ||
puts opts | ||
exit | ||
end | ||
end | ||
|
||
args = o.order!(ARGV) {} | ||
o.parse!(args) | ||
|
||
legacy_mysql = Mysql2::Client.new({:host => options['host'], :username => options['username'], :database => options['database'], :password => options['password']}) | ||
|
||
legacy_news = legacy_mysql.query("SELECT * FROM #{options[:tableprefix]}_news") | ||
legacy_queue = legacy_mysql.query("SELECT * FROM #{options[:tableprefix]}_queue") | ||
legacy_quotes = legacy_mysql.query("SELECT * FROM #{options[:tableprefix]}_quotes") | ||
|
||
legacy_news.each do |legacy_announcement| | ||
puts "Migrating legacy announcement #{legacy_announcement['id']}" | ||
announcement = Announcement.new(text: legacy_announcement['news'], created_at: Time.at(legacy_quote['date'])) | ||
announcement.save | ||
end | ||
|
||
legacy_queue.each do |legacy_quote| | ||
puts "Migrating legacy queued quote #{legacy_quote['id']}" | ||
quote = Quote.new(text: legacy_quote['quote'], created_at: Time.at(legacy_quote['date'])) | ||
quote.save | ||
end | ||
|
||
legacy_quotes.each do |legacy_quote| | ||
puts "Migrating legacy quote #{legacy_quote['id']}" | ||
is_flagged = case legacy_quote['flag'] | ||
when 1 | ||
true | ||
else | ||
false | ||
end | ||
quote = Quote.new(text: legacy_quote['quote'], score: legacy_quote['rating'], flagged: legacy_quote['flag'], approved: true, created_at: Time.at(legacy_quote['date'])) | ||
quote.save | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters