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

Upgrade to mySQL5.7, Ruby warning reductions, .md file updates #355

Merged
merged 19 commits into from
Mar 11, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gem "friendly_id"

# dependencies
group :dependencies do
gem 'mysql2', '~> 0.3.20'
gem 'mysql2', '< 0.4'
gem "geokit-rails", "1.1.4"
gem "image_science", "1.2.6"
gem "recaptcha", :require => "recaptcha/rails"
Expand All @@ -31,7 +31,7 @@ group :dependencies do

# asset pipelining
gem "sprockets"#, "2.12.1"
gem "sass"
gem "sass", :require => 'sass'
gem "autoprefixer-rails"
gem "uglifier"

Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ GEM
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
arel (3.0.3)
autoprefixer-rails (9.4.7)
autoprefixer-rails (9.4.8)
execjs
aws-sdk (1.5.8)
httparty (~> 0.7)
Expand Down Expand Up @@ -160,7 +160,7 @@ GEM
execjs (>= 0.3.0, < 3)
uuidtools (2.1.5)
will_paginate (3.1.6)
will_paginate-bootstrap (1.0.1)
will_paginate-bootstrap (1.0.2)
will_paginate (>= 3.0.3)

PLATFORMS
Expand All @@ -174,7 +174,7 @@ DEPENDENCIES
geokit-rails (= 1.1.4)
image_science (= 1.2.6)
jshintrb
mysql2 (~> 0.3.20)
mysql2 (< 0.4)
oa-openid (= 0.3.2)
open_id_authentication
paperclip (~> 4.2.2)
Expand All @@ -198,4 +198,4 @@ RUBY VERSION
ruby 2.4.4p296

BUNDLED WITH
1.16.2
1.17.1
149 changes: 149 additions & 0 deletions MYSQL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# installation troubleshooting & instructions

## System Agnostic

- bundler skipping over **mysql2** gem?

```Bash

$ rm .bundle/config

$ bundle exec bundle install

```



## MacOS

**Homebrew setup:**

(Note: alternative to Homebrew is [mySQL community server](https://dev.mysql.com/downloads/mysql/5.7.html#downloads) - available for all systems)

Dependencies:

- `cmake`

- `openssl`

```Bash

$ brew install cmake

$ brew install openssl

```

Installation:

```Bash

#make sure you don't have any other versions of mysql installed
$ brew list

#if you do
$ brew uninstall <mysql@x.x>
$ brew unlink <mysql@x.x>

#install 5.7
$ brew install mysql@5.7

$ brew link mysql@5.7 --force
```

Test Usage:

```Bash

# install brew services
$ brew tap homebrew/services

# cmd to run always - suggest aliasing this in your bash profile
$ brew services start mysql@5.7

#confirm its running
$ brew services list

# cmd to stop running
$ brew services stop mysql@5.7

```

Update Permissions

```Bash
# check for right permissions to the PIDs
$ ls -laF /usr/local/var/mysql/

# if the owner is root you should change it to mysql or username
$ sudo chown -R <username> /usr/local/var/mysql/

# confirm updated permissions
$ ls -laF /usr/local/var/mysql/

```

Account Setup

```Bash
# secure your account
$ mysql_secure_installation

# set password
$ mysqladmin -u root password <newpassword>
# login -- not root anymore
$ mysql -u <username> -p <password>

```

Permission issues above?

(note these commands also fix the error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2))

```Bash

$ mysql.server stop

#unset the temporary directory
$ echo $TMPDIR
$ unset TMPDIR
$ echo $TMPDIR

$ whoami

$ mysqld -initialize --verbose --user=$(whoami) --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

#restart mysql
$ mysql.server restart


$ mysql -u root

#You should now be in the mysql command line shell
mysql> SELECT User, Host, authentication_string FROM mysql.user;

mysql> rename user 'root'@'localhost' to '<yourUsername>'@'localhost';

#confirm
mysql> SELECT User, Host, authentication_string FROM mysql.user;

mysql> flush privileges;

mysql> exit

```

Reconfirm Access

(whenever want to access the mysql db locally, need to run this login first - suggest aliasing in bash profile)

```Bash

$ mysql -u <username> -p

```



## Pending: please add instructions for your respective system

2 changes: 2 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
References \#0000 (\<=== Add issue number here)

Make sure these boxes are checked before your pull request is ready to be reviewed and merged. Thanks!

* [ ] tests pass -- `rake test`
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ Once NPM is installed, you should be able to run:

## Installation

You'll need at least Ruby v1.9.3 (**v2.1.x** preferred)
You'll need Ruby v2.4.4 (use your local ruby version management system - RVM / rbenv / etc. - to install and set locally)

1. Download a copy of the source with `git clone https://github.com/publiclab/mapknitter.git`
2. Install gems with `bundle install` from the rails root folder. You may need to run `bundle update` if you have older gems in your environment.
3. Copy and configure config/database.yml from config/database.yml.example, using a new empty database you've created
4. Copy and configure config/config.yml from config/config.yml.example (for now, this is only for the [Google Maps API Key, which is optional](http://stackoverflow.com/questions/2769148/whats-the-api-key-for-in-google-maps-api-v3))
5. Initialize database with `bundle exec rake db:setup`
6. Enter ReCaptcha public and private keys in config/initializers/recaptcha.rb, copied from recaptcha.rb.example. To get keys, visit https://google.com/recaptcha/admin
6. Enter ReCaptcha public and private keys in config/initializers/recaptcha.rb, copied from recaptcha.rb.example. To get keys, visit https://www.google.com/recaptcha/admin/create
7. Install static assets (like external javascript libraries, fonts) with `bower install`
8. Start rails with `bundle exec passenger start` from the Rails root and open http://localhost:3000 in a web browser. (For some, just `passenger start` will work; adding `bundle exec` ensures you're using the version of passenger you just installed with Bundler.)

Expand Down
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Mapknitter::Application.load_tasks
Mapknitter::Application.load_tasks
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def require_login
unless logged_in?
path_info = request.env['PATH_INFO']
flash[:warning] = "You must be logged in to access this section"
redirect_to '/login?back_to=' + URI.encode(path_info) # halts request cycle
redirect_to '/login?back_to=' + path_info.to_param # halts request cycle
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ def csrf_meta_tags
out % [ Rack::Utils.escape_html(request_forgery_protection_token),
Rack::Utils.escape_html(form_authenticity_token) ]
end
end
end

end
6 changes: 3 additions & 3 deletions app/models/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def average_cm_per_pixel
res = 1 if res == 0 # let's not ever try to go for infinite resolution
scales << res unless res == nil
end
sum = (scales.inject {|sum, n| sum + n }) if scales
average = sum/count if sum
total_sum = (scales.inject {|sum, n| sum + n }) if scales
average = total_sum/count if total_sum
average
else
0
Expand Down Expand Up @@ -384,7 +384,7 @@ def has_tag(tagname)
def add_tag(tagname, user)
tagname = tagname.downcase
unless self.has_tag(tagname)
tag = self.tags.create({
self.tags.create({
:name => tagname,
:user_id => user.id,
:map_id => self.id
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def email=(value)
end

def last_action
map = self.maps.order('updated_at DESC').limit(1).first.updated_at
self.maps.order('updated_at DESC').limit(1).first.updated_at
end

# Permissions for editing and deleting resources
Expand Down
4 changes: 2 additions & 2 deletions app/models/warpable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ def generate_perspectival_distort(pxperm,path)
# everything in -working/ can be deleted;
# this is just so we can use the files locally outside of s3
working_directory = self.working_directory(path)
Dir.mkdir(working_directory) unless (File.exists?(working_directory) && File.directory?(working_directory))
Dir.mkdir(working_directory) unless (File.exist?(working_directory) && File.directory?(working_directory))
local_location = working_directory+self.id.to_s+'-'+self.image_file_name.to_s

directory = self.warps_directory(path)
Dir.mkdir(directory) unless (File.exists?(directory) && File.directory?(directory))
Dir.mkdir(directory) unless (File.exist?(directory) && File.directory?(directory))
completed_local_location = directory+self.id.to_s+'.png'

# everything -masked.png can be deleted
Expand Down
2 changes: 1 addition & 1 deletion config/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
17 changes: 0 additions & 17 deletions config/initializers/new_rails_defaults.rb

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
db:
image: mysql:5.6
image: mysql:5.7
environment:
- MYSQL_DATABASE=mapknitter
- MYSQL_USER=mapknitter
Expand Down
3 changes: 2 additions & 1 deletion lib/cartagen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.spherical_mercator_lat_to_y(lat,scale=10000)
y * scale / 180
end

def self.spherical_mercator_y_to_lat(y,scale=10000)
def self.spherical_mercator_y_to_lat(y,scale=10000)
#180/Math::PI * (2 * Math.atan(Math.exp(y/scale_factor*Math::PI/180)) - Math::PI/2)
lat = (y / scale) * 180
180/Math::PI * (2 * Math.atan(Math.exp(lat * Math::PI / 180)) - Math::PI / 2)
Expand All @@ -29,6 +29,7 @@ def self.spherical_mercator_y_to_lat(y,scale=10000)
# collects coastline ways into collected_way relations;
# see http://wiki.openstreetmap.org/wiki/Relations/Proposed/Collected_Ways
def self.collect_ways(features)
# collected_ways variable unused review this function
collected_ways = []
nodes = {}
features['osm']['node'].each do |node|
Expand Down
5 changes: 3 additions & 2 deletions lib/gdal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ def self.ulimit
end

def self.raw(cmd,verbose)
# unused variable stdin review this function
stdin, stdout, stderr = Open3.popen3(self.ulimit+cmd)
if verbose
puts stderr.readlines
puts stdout.readlines
puts stderr.readlines
puts stdout.readlines
end
end

Expand Down
1 change: 1 addition & 0 deletions libmysqlclient.18.dylib