whithub / traffic-spy Goto Github PK
View Code? Open in Web Editor NEWThis project forked from turingschool-examples/rush-hour-skeleton
This project forked from turingschool-examples/rush-hour-skeleton
As a user, when I go to .../sources/(identifier)/events but there are no events, I should get a message that says so.
As a user, when I go to .../sources/(identifier)/events/(eventname) I should see the number of times each event was received for every hour of the day.
When a user navigates to http://yourapplication:port/sources/IDENTIFIER/events/EVENTNAME for an undefined event, they get a message that says "No event of this name has been defined" and a hyperlink back to the applications event index
Possible Outcomes:
As a user,
When I send a POST request to
http://yourapplication:port/sources/IDENTIFIER/data
with a Missing Payload
Then I expect a 400 Bad Request response with a descriptive error message.
As a user,
When I send a POST request to
http://yourapplication:port/sources/IDENTIFIER/data
with an identical payload
Then I expect a 403 Forbidden response with a descriptive error message that it's
"Already Received Request"
As a user,
When I send a POST request to
http://yourapplication:port/sources/IDENTIFIER/data
with an unknown Identifier
Then I expect a 403 Forbidden response with a descriptive error message that
"Application Not Registered"
As a user,
When I send a POST request to
http://yourapplication:port/sources/IDENTIFIER/data
with a unique identifier and payload
Then I expect a Success - 200 OKresponse and POST is complete
As a user, when I go to .../sources/(identifier) I should see the screen resolution (or window size) my website was viewed in, in descending order of frequency.
when a user goes to localhost/port/sources/identifier, they see a list of all the statistics, starting with most requested urls.
When a user navigates to http://yourapplication:port/sources/IDENTIFIER/events/EVENTNAME for an event that has bee defined, they can view hour by hour breakdown of when the event was received and how many times it was received overall
A source has_many payloads
And a payload belongs to one sources
As a client,
When I send a GET request to
http://yourapplication:port/sources/IDENTIFIER/events/EVENTNAME
with defined event
Then I expect to be returned a page that displays the following;
Hour by hour breakdown of when the event was received.
How many were shown per hour?
How many were shown in 24 hours?
How many times it was recieved overall
As a client,
When I send a GET request to
http://yourapplication:port/sources/IDENTIFIER/events/EVENTNAME
with an event that has been not defined
Then I expect to be returned a 400 Bad Request response with a descriptive error message that states "o event with the given name has been defined".
Create view files for:
Index
Error
Sources
Data
Event(s)
URL Stats
rake db:create_migration NAME=create_sources_table..
rake db:create_migration NAME=create_payloads_table
add_column to payloads tables with each payload attribute, as we go...
As a user, when I go to .../sources/(identifier) I should see all of my site's URLs in descending order of average response time.
As a user, when I go to .../sources/(identifier) I should see all of my site's URLs in descending order by the number of times they were requested.
As a client,
When I send a GET request to
http://yourapplication:port/sources/IDENTIFIER
with an existing identifier
Then I expect to be returned a page that displays the following;
Most requested URLS to least requested URLS (url)
Web browser breakdown across all requests (userAgent)
OS breakdown across all requests (userAgent)
Screen Resolution across all requests (resolutionWidth x resolutionHeight)
Longest, average response time per URL to shortest, average response time per URL
Hyperlinks of each url to view url specific data
Hyperlink to view aggregate event data
As a client,
When I send a GET request to
http://yourapplication:port/sources/IDENTIFIER
with an identifier that does not exist/was not registered
Then I expect to be returned a 403 Forbidden response with a descriptive error message that states "Identifier does not exist"
As a user,
When I send a POST request to
http://yourapplication:port/sources
with the parameters
'identifier=jumpstartlab&rootUrl=http://jumpstartlab.com'
Then return status of 200 OK with the data {"identifier":"jumpstartlab"} as JSON
As a user,
When I send a POST request to
http://yourapplication:port/sources
with the parameters
'rootUrl=http://jumpstartlab.com'
Then I expect a 400 response with the data "Please provide an identifier"
Split up view files to HTML/CSS btwn group. STYLE!
Index -- Erik
Error -- Erik
Sources -- Whitney
Data -- Whitney
Event(s) -- Lev
URL Stats - Lev
As a user, when I go to .../sources/(identifier)/events I should see all the events which lead to my website as links to view more information about that event.
As a user, when I go to .../sources/(identifier)/events/(eventname) I should see the total number of times that event was received.
As a client,
When I send a GET request to
http://yourapplication:port/sources/IDENTIFIER/urls/RELATIVE/PATH
with an existing url
Then I expect to be returned a page that displays the following;
Longest response time
Shortest response time
Average response time
Which HTTP verbs have been used
Most popular referrrers
Most popular user agents
As a client,
When I send a GET request to
http://yourapplication:port/sources/IDENTIFIER/urls/RELATIVE/PATH
with an url that does not exist
Then I expect to be returned a 400 Bad Request response with a descriptive error message that states "URL has not been requested"
As a user,
when I visit http://yourapplication:port/sources/IDENTIFIER/urls/RELATIVE/PATH
I expect to see the
a list of the most popular referrers
and a list of the most popular user agents
As a user, when I go to .../sources/(identifier) I should see the web browsers and operating systems used by the visitors to my site, in descending order of frequency.
As a user,
when I visit http://yourapplication:port/sources/IDENTIFIER/urls/RELATIVE/PATH
I expect to see the
longest, shortest, and average response times for that url
Digest::SHA1.hexdigest(string_payload) --- Wil provide the incoming string payload to be unique. Will be usful with error messages and whether or not this request already exists.
As a user, when I go to .../sources/(identifier) but the identifier doesn't exist, I should get a message saying so.
@DaTa = JSON.parse(string payload)
JSON changes the incoming string payload into a hash that we'll be able to use when we get to storing each attribute of the payload in our table and referencing it later.
t.text :payhash
t.text :url
t.datetime :requestedat
t.integer :respondedin
t.text :referredby
t.text :requesttype
t.varchar :parameters
t.text :eventname
t.text :useragent
t.integer :resolutionwidth
t.integer :resolutionheight
t.integer :ip
datetime might be tricky..... UTC format once in ActiveRecord
As a user, when I go to .../sources/(identifier) I should see all of my site's URLs and links to a page to get more specific information about each one as well as a link to view information by event.
SO TRICKY!!!
RegEx??
Web browser breakdown across all requests (userAgent)
We need to pull out each browser within the userAgent attribute in teh payload.
OS breakdown across all requests (userAgent)
As a user, when I go to .../sources/(identifier)/events/(eventname) but there isn't an event with that name, I should see a message to that effect and a link back to the main events index.
*source_test
*payload_test
test_incoming_payload_attributes_get_assigned
*source_validator_test
*payload_validator_test
test_incoming_payload_attributes_get_saved_to_payloads_table
As a user, when I go to .../sources/(identifier)/events I should see all the events which lead to my website in descending order of frequency.
parsed_payload = JSON.parse the incoming string payload
Further parse the "parsed_payload" into the payloads table & save.
Do so by assigning the value of each (camelcased) key in the parsed_payload hash to a (snake_cased) named column that matches that key.
(request_at = requestedAt)
As a user,
when I visit http://yourapplication:port/sources/IDENTIFIER/urls/RELATIVE/PATH
I expect to see the
all the HTTP verbs, such as GET, POST, PUT, DELETE
that have been used.
test_invalid_identifier_errors
Missing Payload - 400 Bad Request
Already Received Request - 403 Forbidden
Application Not Registered - 403 Forbidden
Success - 200 OK
test_valid_payload_structure_gets_logged
test_already_received_payload
Work through together as group? Or split up work?
When an identifer exists return a page that displays the following:
Most requested URLS to least requested URLS (url)
Web browser breakdown across all requests (userAgent)
OS breakdown across all requests (userAgent)
Screen Resolution across all requests (resolutionWidth x resolutionHeight)
Longest, average response time per URL to shortest, average response time per URL
Hyperlinks of each url to view url specific data
Hyperlink to view aggregate event data
When an identifier does not exist return a page that displays the following:
Message that the identifier does not exist
As a user,
when I visit http://yourapplication:port/sources/IDENTIFIER/urls/RELATIVE/PATH
with an unknown url
I expect to see the home page of Traffic Spy and see an error, reading:
400 Bad Request
Missing Payload - 400 Bad Request
Already Received Request - 403 Forbidden
Application Not Registered - 403 Forbidden
Success - 200 OK
By using last_response.status and last_response.body:
test_valid_registration_with_identifier_and_rooturl
test_invalid_registration_with_no_identifier
test_invalid_registration_with_no_rooturl
test_invalid_registration_with_existent_identifier
Make a unique key for each payload (SHA) that will help identify/validate it later on so the app can recognize if two identical payloads are being submitted.
If the payload is missing return status 400 Bad Request with a descriptive error message.
If the request payload has already been received return status 403 Forbidden with a descriptive error message.
When data is submitted to an application URL that does not exist, return a 403 Forbidden with a descriptive error message.
When the request contains a unique payload return status 200 OK.
As a client,
When I send a GET request to
http://yourapplication:port/sources/IDENTIFIER/events
with defined events
Then I expect to be returned a page that displays the following;
Most received event to least received event
Hyperlinks of each event to view event specific data
As a client,
When I send a GET request to
http://yourapplication:port/sources/IDENTIFIER/events
with events have been not defined
Then I expect to be returned a 400 Bad Request response with a descriptive error message that states "no events have been defined".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.