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

Nicole testing #176

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
f6309dd
finished 0, moving to one
NicoleKMarino Jul 6, 2016
15b98f5
more models and tests and tables and shit
NicoleKMarino Jul 6, 2016
73bee43
commit-madded test file for PayloadRequests and created teardown method
NicoleKMarino Jul 7, 2016
8c27470
Merge pull request #12 from NicoleKMarino/iteration_2_nicole
twhitinger Jul 7, 2016
b0afb4d
Iteration one needs some clean up. Includes start of iteration 2
kbs5280 Jul 7, 2016
d3fef89
Merge pull request #19 from NicoleKMarino/iteration_2
twhitinger Jul 7, 2016
2e405ed
fixed test and sanitation and rake file n shit
NicoleKMarino Jul 7, 2016
7f74f62
got all tests working yeah
NicoleKMarino Jul 7, 2016
4fb93d6
fixed realtionships
NicoleKMarino Jul 7, 2016
6737f6b
http request methods and tests
NicoleKMarino Jul 8, 2016
279d295
json parser, test helper payload, software agent model
twhitinger Jul 8, 2016
846aaaa
Merge pull request #23 from NicoleKMarino/trent_1
twhitinger Jul 8, 2016
6a3fc1d
Additional tests
kbs5280 Jul 8, 2016
8498a23
Merge pull request #24 from NicoleKMarino/iteration_2_ks
kbs5280 Jul 8, 2016
b93371d
Test refactoring
kbs5280 Jul 8, 2016
7eb337a
Merge pull request #33 from NicoleKMarino/28_response_times
kbs5280 Jul 8, 2016
c6a4191
all tables working through execept software_agent and referrer
twhitinger Jul 8, 2016
3b037ea
Min and max working
kbs5280 Jul 8, 2016
362e147
Merge pull request #34 from NicoleKMarino/28_response_times
kbs5280 Jul 8, 2016
f158e08
trying to add uniqueness
NicoleKMarino Jul 8, 2016
65ea897
URL specific methods
NicoleKMarino Jul 8, 2016
0aa4e53
test
twhitinger Jul 8, 2016
c89330c
the basic tests and for iteration 4 complete
twhitinger Jul 9, 2016
8e5b67a
Added create unique payloads to test_helper
kbs5280 Jul 9, 2016
899222a
Merge pull request #35 from NicoleKMarino/saturday_morning_10am
NicoleKMarino Jul 9, 2016
51cf512
refactored repetitive code and added find average by url method
NicoleKMarino Jul 9, 2016
b8f97a0
Active record method for urls
kbs5280 Jul 9, 2016
c5f15d2
Merge pull request #36 from NicoleKMarino/saturday_morning_10am
kbs5280 Jul 9, 2016
4ca8b09
minor things
kbs5280 Jul 9, 2016
2ce7842
added hhtp request types methods
NicoleKMarino Jul 9, 2016
f8b8815
Merge branch 'master' of https://github.com/NicoleKMarino/rush-hour
NicoleKMarino Jul 9, 2016
56f4b0d
added http type methods
NicoleKMarino Jul 9, 2016
27d2e36
tests pass through iteration 4 starting 5
twhitinger Jul 9, 2016
78f7fd5
some other things
kbs5280 Jul 9, 2016
46396c5
Fixed payload test
kbs5280 Jul 9, 2016
1944925
Merge pull request #39 from NicoleKMarino/saturday_around_noon
kbs5280 Jul 9, 2016
9323f0a
Merge branch 'iteration_4'
twhitinger Jul 9, 2016
612e24f
all iterations merged, need to fix tests
twhitinger Jul 9, 2016
cb5b573
Iteration 2 almost complete, needs referrer method
kbs5280 Jul 9, 2016
7aad66c
Working on iteration 5
kbs5280 Jul 9, 2016
d89730b
Iteration 5, needs routes
kbs5280 Jul 9, 2016
a7619ab
Added tests and methods for rerlerjejafldlaj
kbs5280 Jul 9, 2016
a5d449e
Supreme Leader added view pages
kbs5280 Jul 9, 2016
9ba6a18
Changes to server and payload request and test file
kbs5280 Jul 9, 2016
5c6fdb3
Building out client model
kbs5280 Jul 9, 2016
210d12a
Added tests and methods for iteration mutherfucking 6
kbs5280 Jul 10, 2016
e364242
front end shit
twhitinger Jul 10, 2016
6e4603a
Iteration 6 complete
kbs5280 Jul 10, 2016
6d0c31d
Merge pull request #54 from NicoleKMarino/iteration_6
twhitinger Jul 10, 2016
17b838d
things
twhitinger Jul 10, 2016
e55a5bc
fuck
twhitinger Jul 10, 2016
3d94db7
iteration 6 first dashboard
twhitinger Jul 10, 2016
1247223
Merge pull request #55 from NicoleKMarino/dean_1
twhitinger Jul 10, 2016
0f84bf7
url specific fucking methods and test shit
kbs5280 Jul 10, 2016
d8dff68
Merge pull request #56 from NicoleKMarino/iteration_7
twhitinger Jul 10, 2016
63b54cd
Views in progress shit
kbs5280 Jul 10, 2016
8fb339a
Merge pull request #57 from NicoleKMarino/iteration_7
twhitinger Jul 10, 2016
4c31a02
maing progress
twhitinger Jul 10, 2016
d8216ad
Merge branch 'master' of https://github.com/NicoleKMarino/rush-hour i…
twhitinger Jul 10, 2016
0287139
Merge pull request #58 from NicoleKMarino/dean_1
twhitinger Jul 10, 2016
ea360b6
Iteration 7 in progress, needs feature testing, some methods need wor…
kbs5280 Jul 11, 2016
f78bb88
Merge pull request #63 from NicoleKMarino/later_in_the_day_on_sunday
twhitinger Jul 11, 2016
4198224
feature testing
kbs5280 Jul 11, 2016
780bd7e
Link working
kbs5280 Jul 11, 2016
eea2e67
final
kbs5280 Jul 11, 2016
a397687
giphy update
kbs5280 Jul 11, 2016
219e2f6
Database seeding working, refactored server, moved business logic dow…
kbs5280 Jul 11, 2016
b973e54
pulled methods into test helper for controller tests
twhitinger Jul 11, 2016
b703bdb
Merge pull request #71 from NicoleKMarino/dean_1
twhitinger Jul 11, 2016
3c0cb35
more robust testing
NicoleKMarino Jul 12, 2016
937682a
Merge pull request #72 from NicoleKMarino/nicole_testing
NicoleKMarino Jul 12, 2016
412361e
all tests pass
twhitinger Jul 12, 2016
d52f6ae
Merge pull request #73 from NicoleKMarino/dean_1
twhitinger Jul 12, 2016
11a5ba1
more feature testing
NicoleKMarino Jul 13, 2016
5f5a84a
Merge pull request #74 from NicoleKMarino/nicole_testing
NicoleKMarino Jul 13, 2016
2ba495d
final edits
NicoleKMarino Jul 13, 2016
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
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
coverage
capybara*.html
\# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ gem 'sinatra', require: 'sinatra/base'
gem 'pg'
gem 'activerecord'
gem 'sinatra-activerecord'
gem 'useragent'

group :development, :test do
gem 'shotgun'
Expand All @@ -12,4 +13,10 @@ group :development, :test do
gem 'capybara'
gem 'launchy'
gem 'rack-test'
gem 'pry'
gem 'database_cleaner'
gem 'simplecov'
gem 'cane'
gem 'reek'
gem 'rake'
end
97 changes: 74 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,47 +1,79 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (4.2.5.1)
activesupport (= 4.2.5.1)
builder (~> 3.1)
activerecord (4.2.5.1)
activemodel (= 4.2.5.1)
activesupport (= 4.2.5.1)
arel (~> 6.0)
activesupport (4.2.5.1)
activemodel (5.0.0)
activesupport (= 5.0.0)
activerecord (5.0.0)
activemodel (= 5.0.0)
activesupport (= 5.0.0)
arel (~> 7.0)
activesupport (5.0.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
arel (6.0.3)
arel (7.0.0)
ast (2.3.0)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
bond (0.5.1)
builder (3.2.2)
capybara (2.6.2)
cane (3.0.0)
parallel
capybara (2.7.1)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
codeclimate-engine-rb (0.3.1)
virtus (~> 1.0)
coderay (1.1.1)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.0.2)
database_cleaner (1.5.3)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
docile (1.1.5)
equalizer (0.0.11)
i18n (0.7.0)
json (1.8.3)
ice_nine (0.11.2)
json (2.0.1)
launchy (2.4.3)
addressable (~> 2.3)
mime-types (3.0)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2015.1120)
mini_portile2 (2.0.0)
minitest (5.8.4)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.0)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
parallel (1.9.0)
parser (2.3.1.2)
ast (~> 2.2)
pg (0.18.4)
pkg-config (1.1.7)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.4)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rainbow (2.1.0)
rake (11.2.2)
reek (4.1.1)
codeclimate-engine-rb (~> 0.3.1)
parser (~> 2.3.1, >= 2.3.1.2)
rainbow (~> 2.0)
ripl (0.7.1)
bond (~> 0.5.1)
ripl-multi_line (0.3.1)
Expand All @@ -52,22 +84,34 @@ GEM
ripl (>= 0.7.0)
shotgun (0.9.1)
rack (>= 1.0)
simplecov (0.12.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
sinatra (1.4.7)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
sinatra-activerecord (2.0.9)
sinatra-activerecord (2.0.10)
activerecord (>= 3.2)
sinatra (~> 1.0)
slop (3.6.0)
thread_safe (0.3.5)
tilt (2.0.2)
tilt (2.0.5)
tux (0.3.0)
ripl (>= 0.3.5)
ripl-multi_line (>= 0.2.4)
ripl-rack (>= 0.2.0)
sinatra (>= 1.2.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
useragent (0.16.7)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
xpath (2.0.0)
nokogiri (~> 1.3)

Expand All @@ -76,15 +120,22 @@ PLATFORMS

DEPENDENCIES
activerecord
cane
capybara
database_cleaner
launchy
minitest
pg
pry
rack-test
rake
reek
shotgun
simplecov
sinatra
sinatra-activerecord
tux
useragent

BUNDLED WITH
1.11.2
1.12.3
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ require "bundler"
Bundler.require

require "sinatra/activerecord/rake"
require "rake/testtask"

Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/*/*.rb']
t.verbose = false
t.warning = false
end
task default: :test #<------ important
namespace :sanitation do
desc "Check line lengths & whitespace with Cane"
task :lines do
Expand Down
44 changes: 42 additions & 2 deletions app/controllers/server.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
module RushHour
class Server < Sinatra::Base
not_found do
erb :error

helpers do
def most_urls
urls = @client.list_urls_from_most_to_least
end
end

post '/sources' do
client = Client.create({identifier: params["identifier"],root_url: params["rootUrl"]})
result = DataLoader.error_check(client)
body result[:body]
status result[:status]
end

post '/sources/:identifier/data' do
parsed_payload = Parser.parse_payload(params["payload"])
result = DataLoader.load(parsed_payload, params["identifier"])

status result[:body]
status result[:status]
end

get '/sources/:identifier' do |identifier|
@identifier = identifier

@client = Client.find_by(identifier: identifier)
payload_requests = @client.payload_requests
erb :dashboard
end

get '/sources/:identifier/urls/:rel_path' do |identifier, rel_path|
@rel_path = rel_path; @identifier = identifier
client = Client.find_by(identifier: identifier)
url = client.find_url_by_relative_path(rel_path)
pass unless url
erb :url_dashboard, locals: { url: url }
end

get '/sources/:identifier/urls/*' do |identifier, splat|

error_message = "No Data for #{splat} for #{identifier.capitalize}"
erb :error, locals: { error_message: error_message }
end
end
end
65 changes: 65 additions & 0 deletions app/models/client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
class Client < ActiveRecord::Base
has_many :payload_requests
has_many :ips, through: :payload_requests
has_many :referrers, through: :payload_requests
has_many :request_types, through: :payload_requests
has_many :resolutions, through: :payload_requests
has_many :urls, through: :payload_requests
has_many :software_agents, through: :payload_requests
has_many :parameters, through: :payload_requests

validates :identifier, presence: true, uniqueness: true
validates :root_url, presence: true, uniqueness: true

def error_message
errors.full_messages.join(", ")
end

def max_response_time
payload_requests.maximum(:responded_in)
end

def min_response_time
payload_requests.minimum(:responded_in)
end

def average_response_time
payload_requests.average(:responded_in).to_i
end

def list_of_all_http_verbs_used
request_types.pluck(:verb).uniq.join(", ")
end

def most_frequent_request_type
request_types.group(:verb).order(count: :desc).count.keys.first
end

def list_urls_from_most_to_least
url_ids = payload_requests.pluck(:url_id).sort.reverse.uniq
url_ids.map { |url_id| Url.find_by(id: url_id).address }
end

def web_browser_breakdown
software_agents.group(:browser).order(count: :desc).count.keys.join
end

def web_os_breakdown
software_agents.group(:os).order(count: :desc).count.keys.join
end

def all_screen_resolutions
res = resolutions.pluck("width, height").uniq
res.map { |r| "#{r.first} X #{r.last}" }.join(", ")
end

def find_url_by_relative_path(relative_path)
full_path = root_url + "/" + relative_path
urls.find_by(address: full_path)
end

def relative_path_exists?(relative_path)
full_path = root_url + "/" + relative_path
!!urls.find_by(address: full_path)
end
end
Loading