Skip to content

bjaxbjax/Usernalysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Usernalysis

User-(a)nalysis charts user data generated from Random User Generator.

Building/Running Usernalysis

Usernalysis is an ASP.Net MVC application developed primarily using C# and javascript. It is built with Visual Studio 2017 Community. To run the app, open the Usernalysis.sln solution file in the project root using Visual Studio and Debug/Start from the IDE.

Usernalysis Usage

An instance of Usernalysis is available on Heroku: https://usernalysis.herokuapp.com/

Submit users data to the app either through file upload or pasting the users data into the provided text input field. Users data must be formatted in JSON.

The set of users must be defined in the results property.

Sample Data Sets

Sample data extracts from Random User Generator can be found here:

Example JSON:

{
  "results": [
    {
      "gender": "male",
      "name": {
        "title": "mr",
        "first": "rolf",
        "last": "hegdal"
      },
      "location": {
        "street": "123 fake street",
        "city": "new york",
        "state": "new york",
        "postcode": "10001"
      },
      "dob": {
        "date": "1975-11-12T06:34:44Z",
        "age": 42
      }
    },{
      "gender": "female",
      "name": {
        "title": "ms",
        "first": "jean",
        "last": "berry"
      },
      "location": {
        "street": "456 rodeo drive",
        "city": "beverly hills",
        "state": "california",
        "postcode": "90210"
      },
      "dob": {
        "date": "2005-11-12T06:34:44Z",
        "age": 13
      }
    }
  ]
}

Once submitted, the web app will render charts with the following analyses

  1. Percentage female versus male
  2. Percentage of first names and last names that start with A‐M versus N‐Z
  3. Percentage of people in each state, up to the top 10 most populous states
  4. Percentage of females in each state, up to the top 10 most populous states
  5. Percentage of males in each state, up to the top 10 most populous states
  6. Percentage of people in the following age ranges: 0‐20, 21‐40, 41‐60, 61‐80, 81‐100, 100+
  7. Top 10 states with the highest average age

Charts related to states contain choropleth maps as an alternative illustration of the data. A switch on the upper-left hand corner of these charts controls the toggle between chart and map.

Since the map is restricted to the United States, it's best to send data with US-based users. For example, users generated by this request:

https://randomuser.me/api/?results=100&nat=us

API

Raw analysis data is available on the following REST API endpoint:

/api/useranalysis

The endpoint accepts POST requests with the JSON-formatted user data in the body of the request or as an uploaded file.

The API can output the analysis in 3 formats:

  • plaintext (default)
  • json
  • xml

Clients can specify the desired format with the request header or the format querystring parameter.

Request header

Set the value for Accept to:

  • text/plain for plaintext
  • application/json for json
  • application/xml for xml

Request header format specification takes precedence over the querystring parameter.

Querystring parameter

Set the value for format to:

  • text for plaintext
  • json for json
  • xml for xml

Example:

https://usernalysis.herokuapp.com/api/useranalysis?format=xml

Example Ajax Request

$.ajax({
  url: 'https://usernalysis.herokuapp.com/api/useranalysis',
  dataType: 'json',
  type: 'POST',
  contentType: 'application/json',
  data: <YOUR USER JSON>,
  success: function(response) {
    console.log(response);
  }
});

Coding Style

Spacing, indenting, and formatting for this web app relies heavily on Visual Studio's default macros for respective front-end (html, css, js) and back-end (C#) files.

Front-end naming and additional coding styles follow conventions outlined by w3schools. Back-end C# code follows microsoft.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published