Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ds2621
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-salvati committed Jun 27, 2017
2 parents 3c6af6f + eb444bd commit 0faca07
Show file tree
Hide file tree
Showing 26 changed files with 418 additions and 39 deletions.
76 changes: 73 additions & 3 deletions .ebextensions/deploy.config
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ files:
sudo usermod -aG appdev ec2-user
sudo usermod -aG appdev webapp
sudo chmod -R 770 /media/volume1
sudo aws s3 sync s3://rsense-media/media/ /media/volume1
sudo aws s3 sync $MEDIA_BUCKET/media/ /media/volume1
sudo chown -R webapp:appdev /media/volume1
true
"/opt/elasticbeanstalk/hooks/appdeploy/post/01_public_media.sh":
Expand All @@ -67,6 +67,19 @@ files:
ln -s /media/volume1 /var/app/current/public/media
sudo chown -R webapp:appdev /var/app/current/public/media
true
"/opt/elasticbeanstalk/hooks/appdeploy/pre/03_git.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
cd /var/app/ondeck/
sudo mkdir git; cd git
sudo git clone https://github.com/isenseDev/rSENSE.git
cd rSENSE; sudo cp -r .git/ ../../
cd /var/app/ondeck/
sudo rm -rf git/
true
"/opt/elasticbeanstalk/hooks/appdeploy/pre/02_postgres_setup.sh":
mode: "000755"
owner: root
Expand Down Expand Up @@ -101,7 +114,7 @@ files:
group: root
content: |
#!/usr/bin/env bash
sudo dd if=/dev/zero of=/swapfile bs=1024 count=256k
sudo dd if=/dev/zero of=/swapfile bs=1024 count=128k
sudo mkswap /swapfile
sudo swapon /swapfile
true
Expand Down Expand Up @@ -139,6 +152,12 @@ files:
group: root
authentication: S3Access
source: https://s3.amazonaws.com/rsense-secrets/policy.xml
"/opt/elasticbeanstalk/support/conf/pumaconf.rb":
mode: "000755"
owner: root
group: root
authentication: S3Access
source: https://s3.amazonaws.com/rsense-secrets/pumaconf.rb
"/home/webapp/.recaptcha_key":
mode: "000755"
owner: ec2-user
Expand Down Expand Up @@ -170,14 +189,65 @@ files:
content: |
0 * * * * root /home/ec2-user/bkpimgs.sh

"/etc/cron.d/memlog":
mode: "000644"
owner: root
group: root
content: |
0,30 * * * * root /home/ec2-user/free.sh >> /var/log/rsensememlog

"/etc/cron.d/restartpuma":
mode: "000644"
owner: root
group: root
content: |
0 4 * * * root /home/ec2-user/restart_puma.sh

"/etc/cron.d/restartpumaif":
mode: "000644"
owner: root
group: root
content: |
20,40 * * * * root /home/ec2-user/restart_puma_if.sh

"/home/ec2-user/bkpimgs.sh":
mode: "000755"
owner: ec2-user
group: ec2-user
content: |
#!/bin/bash
sudo aws s3 sync /media/volume1 $MEDIA_BUCKET/media/
date > /tmp/imgbkplastdate
sudo aws s3 sync /media/volume1 s3://rsense-media/media/
exit 0
"/home/ec2-user/restart_puma.sh":
mode: "000755"
owner: ec2-user
group: ec2-user
content: |
#!/bin/bash
sudo kill -s SIGUSR2 `cat /var/run/puma/puma.pid`
date >> /tmp/pumarestartlastdate
exit 0
"/home/ec2-user/restart_puma_if.sh":
mode: "000755"
owner: ec2-user
group: ec2-user
content: |
#!/bin/bash
free=`free -mt | grep Total | awk '{print $4}'`
if [ $free -lt 500 ]; then
sudo kill -s SIGUSR2 `cat /var/run/puma/puma.pid`
date >> /tmp/pumarestartlastdate
fi
exit 0
"/home/ec2-user/free.sh":
mode: "000755"
owner: ec2-user
group: ec2-user
content: |
#!/bin/bash
echo " date time $(free -m | grep total | sed -E 's/^ (.*)/\1/g')"
echo "$(date '+%Y-%m-%d %H:%M:%S') $(free -m | grep Mem: | sed 's/Mem://g')"
exit 0


Expand Down
12 changes: 5 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ source 'https://rubygems.org'
gem 'puma'
gem 'rails', '~> 4.1.4'

gem 'sqlite3'
gem 'pg'

gem 'coffee-rails'
Expand All @@ -22,6 +21,7 @@ gem 'sprockets', '~> 2.12'

# Integration testing stuff
group :development, :test do
gem 'sqlite3'
gem 'capybara'
gem 'selenium-webdriver'
gem 'launchy'
Expand All @@ -34,6 +34,7 @@ group :development, :test do
gem 'capybara-screenshot'
gem 'html5_validator'
gem 'byebug'
gem 'derailed'
end

# Jquery stuff
Expand Down Expand Up @@ -70,12 +71,6 @@ gem 'will_paginate-bootstrap'
# Include Remotipart
gem 'remotipart'

# To allow coffescript views
gem 'coffeebeans'

# Include newer version of WEBrick
gem 'webrick'

gem 'mini_magick'

# Database serialization
Expand All @@ -102,3 +97,6 @@ gem 'beaker', '~> 1.3.0', git: 'https://github.com/isenseDev/beaker-lang'
# User System
gem 'devise'
gem "omniauth-google-oauth2"

# still necessary?
gem 'coffeebeans'
19 changes: 16 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ GEM
bcrypt (3.1.9)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
benchmark-ips (2.7.2)
bootstrap-sass (3.3.3)
autoprefixer-rails (>= 5.0.0.1)
sass (>= 3.2.19)
Expand Down Expand Up @@ -126,6 +127,16 @@ GEM
coffee-script
execjs
json
derailed (0.1.0)
derailed_benchmarks
derailed_benchmarks (1.3.2)
benchmark-ips (~> 2)
get_process_mem (~> 0)
heapy (~> 0)
memory_profiler (~> 0)
rack (>= 1)
rake (> 10, < 13)
thor (~> 0.19)
devise (3.5.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand All @@ -145,6 +156,7 @@ GEM
filigree (0.3.3)
font-awesome-rails (4.4.0.0)
railties (>= 3.2, < 5.0)
get_process_mem (0.2.1)
handlebars (0.6.0)
handlebars-source (~> 1.3.0)
therubyracer (~> 0.12.0)
Expand All @@ -155,6 +167,7 @@ GEM
sprockets (>= 2.0.3)
tilt
hashie (3.4.3)
heapy (0.1.2)
hike (1.2.3)
html5_validator (1.0.0)
json
Expand Down Expand Up @@ -184,6 +197,7 @@ GEM
libv8 (3.16.14.7)
mail (2.6.3)
mime-types (>= 1.16, < 3)
memory_profiler (0.9.8)
mime-types (2.6.1)
mini_magick (4.0.1)
mini_portile (0.6.2)
Expand Down Expand Up @@ -325,7 +339,6 @@ GEM
useragent (0.10.0)
warden (1.2.3)
rack (>= 1.0)
webrick (1.3.1)
websocket (1.2.2)
will_paginate (3.0.7)
will_paginate-bootstrap (1.0.1)
Expand Down Expand Up @@ -353,6 +366,7 @@ DEPENDENCIES
coffee-rails-source-maps
coffeebeans
coffeelint
derailed
devise
execjs
font-awesome-rails (~> 4.4.0.0)
Expand Down Expand Up @@ -389,10 +403,9 @@ DEPENDENCIES
touchpunch-rails
uglifier
useragent (~> 0.10.0)
webrick
will_paginate
will_paginate-bootstrap
yaml_db!

BUNDLED WITH
1.14.6
1.15.1
1 change: 1 addition & 0 deletions app/assets/images/compass.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/contact/david_nguyen.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions app/assets/javascripts/google_analytics.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
class @GoogleAnalytics

@load: ->
# Google Analytics depends on a global _gaq array. window is the global scope.
window._gaq = []
window._gaq.push ["_setAccount", GoogleAnalytics.analyticsId()]

# Create a script element and insert it in the DOM
ga = document.createElement("script")
ga.type = "text/javascript"
ga.async = true
ga.src = ((if "https:" is document.location.protocol then "https://ssl" else "http://www")) + \
".google-analytics.com/ga.js"
firstScript = document.getElementsByTagName("script")[0]
firstScript.parentNode.insertBefore ga, firstScript

# If Turbolinks is supported, set up a callback to track pageviews on page:change.
# If it isn't supported, just track the pageview now.
if typeof Turbolinks isnt 'undefined' and Turbolinks.supported
document.addEventListener "page:change", (->
GoogleAnalytics.trackPageview()
), true
else
GoogleAnalytics.trackPageview()

@trackPageview: (url) ->
unless GoogleAnalytics.isLocalRequest()
if url
window._gaq.push ["_trackPageview", url]
else
window._gaq.push ["_trackPageview"]
window._gaq.push ["_trackPageLoadTime"]

@isLocalRequest: ->
GoogleAnalytics.documentDomainIncludes "local"

@documentDomainIncludes: (str) ->
document.domain.indexOf(str) isnt -1

@analyticsId: ->
# your google analytics ID(s) here...
'UA-101586720-1'

GoogleAnalytics.load()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="full-width">
<div class="vis-ctrl-tip" data-log-id="ctrl-tip">
<p><strong>Bar graph not looking helpful?</strong><br>
Try grouping by <a id='control-tip-link'>{{field}}.</a></p>
</div>
</div>
38 changes: 38 additions & 0 deletions app/assets/javascripts/visualizations/highvis/bar.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,43 @@ $ ->

options

###
Draws control to suggest grouping option
###
drawGroupingTip: () ->

# Local function which creates the alert
recommend = (field) ->
ctx = {}
ctx.field = field
tip = HandlebarsTemplates[hbCtrl('tip')](ctx)
$('#vis-ctrls').append tip

# Can't give good suggestion if only one point
if data.dataPoints.length > 1
# If there is only one bar
if data.groups.length is 1
# Find a text field to suggest
if data.userTextFields.length isnt 0
gid = globals.configs.groupById
# Select any random text field
while gid == globals.configs.groupById
gid = data.userTextFields[Math.floor(Math.random() * data.userTextFields.length)]
recommend(data.fields[gid].fieldName)
# If there are multiple datasets, suggest group by dataset
else if data.includesMultipleDatasets
gid = data.DATASET_NAME_FIELD
recommend("Data Set")
# Note: otherwise we are doing nothing
# Bind the link to changing the vis
$('#control-tip-link').click () =>
data.setGroupIndex(gid)
globals.configs.groupById = gid
data.groupSelection = for vals, keys in data.groups
Number(keys)
@delayedUpdate()
@drawControls()

drawControls: ->
super()
# Remove group by number fields, only for pie chart
Expand All @@ -389,6 +426,7 @@ $ ->
# Remove Group By Time Period if there is no time data
if data.hasTimeData is false or data.timeType == data.GEO_TIME
groups.splice(data.TIME_PERIOD_FIELD - 2, 1)
@drawGroupingTip()
@drawGroupControls(groups)
@drawYAxisControls(globals.configs.fieldSelection,
data.normalFields.slice(1), false)
Expand Down
17 changes: 17 additions & 0 deletions app/assets/javascripts/visualizations/highvis/highmodifiers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ $ ->

delete data.savedData

# Extra "reserved" fields that are always added
data.DATA_POINT_ID_FIELD = 0
data.DATASET_NAME_FIELD = 1
data.COMBINED_FIELD = 2
data.NUMBER_FIELDS_FIELD = 3
data.CONTRIBUTOR_FIELD = 4
data.TIME_PERIOD_FIELD = 5
# Helps determine where user-defined fields start
data.NUMBER_RESERVED_FIELDS = 6

data.types ?=
TIME: 1
Expand Down Expand Up @@ -487,6 +490,20 @@ $ ->
data.textFields = for field, index in data.fields when (Number field.typeID) is data.types.TEXT
Number index

###
Gets a list of USER text field indicies
###
data.userTextFields = data.textFields.filter (n) -> n > (data.NUMBER_RESERVED_FIELDS - 1)

###
Boolean, whether there is more than one data set
###
for dp in data.dataPoints
if dp[1] isnt data.dataPoints[0][1]
data.includesMultipleDatasets = true
break
data.includesMultipleDatasets = false

###
Gets a list of time field indicies
###
Expand Down
Loading

0 comments on commit 0faca07

Please sign in to comment.