scout-app / scout-app.github.io

Repo for the official website of the desktop app, Scout-App.
http://Scout-App.io
6 stars 2 forks source link

Download Dashboard - Create an API for daily stats #4

Open TheJaredWilcurt opened 7 years ago

TheJaredWilcurt commented 7 years ago

This feature would go on the alternative downloads dashboard:

  1. Set up AWS Lambdas or something so it will run once a day
  2. Have it get the total number of downloads from GitHub's API
  3. Store that data with a timestamp somewhere that can be publicly retrieved. Something like this:
    [
    {
        "timeStamp": 1479081510000,
        "time": "Sun Nov 13 2016 23:58:30 GMT-0500 (Eastern Standard Time)",
        "total": 282611,
        "sa0": {
            "total": 274291,
            "osdist": {
                "win": 192084,
                "lin32": 0,
                "lin64": 0,
                "osx": 82207
            }
        },
        "sa2": {
            "total": 8320,
            "osdist": {
                "win": 6439,
                "lin32": 104,
                "lin64": 342,
                "osx": 1435
            }
        }
    },
    {
        "timeStamp": 1479167910000,
        "time": "Sun Nov 14 2016 23:58:30 GMT-0500 (Eastern Standard Time)",
        "total": 282700,
        "sa0": {
            "total": 274291,
            "osdist": {
                "win": 192084,
                "lin32": 0,
                "lin64": 0,
                "osx": 82207
            }
        },
        "sa2": {
            "total": 8409,
            "osdist": {
                "win": 6499,
                "lin32": 105,
                "lin64": 348,
                "osx": 1457
            }
        }
    },
    {
        "timeStamp": 1479254310000,
        "time": "Sun Nov 15 2016 23:58:30 GMT-0500 (Eastern Standard Time)",
        "total": 282936,
        "sa0": {
            "total": 274291,
            "osdist": {
                "win": 192084,
                "lin32": 0,
                "lin64": 0,
                "osx": 82207
            }
        },
        "sa2": {
            "total": 8645,
            "osdist": {
                "win": 6610,
                "lin32": 115,
                "lin64": 392,
                "osx": 1528
            }
        }
    }
    ]
  4. Create a UI to consume that public route and display a line graph.
  5. Calculate the average downloads a day and display them on the page.

These tasks can be split up and done by different people. It is just a general outline.

TLDR: Get the amount of downloads Scout-App has had from GitHub once a day and store them somewhere. Get that stored data and put it in a UI on the Downloads Dashboard.

TheJaredWilcurt commented 7 years ago

To get the data for this, you'll need to hit 3 public API routes from GitHub, parse and combine the data.

This is already being on the current dashboard page. Some some of that code could be improved or repurposed.


An explanation of what we expect the route to return

[ // Each day is an object in an array to make looping through it easier
    {
        // Unix timestamp from when the data was captured from the APIs (`Date.now()`)
        "timeStamp": 1478451600000,
        // Timestamp in plain English, doesn't have to match this format exactly (`new Date`)
        "time": "Sun Nov 06 2016 16:00:00 GMT-0500 (Eastern Standard Time)",
        "total": 282611,       // Total count for all downloads of Scout-App ever
        "sa0": {
            "total": 274291,   // Total count for all downloads of Scout-App Classic (0.x.x)
            "osdist": {
                "win": 192084, // Total count for all Windows downloads of Scout-App Classic
                "lin32": 0,    // Total count for all Linux 32-bit downloads of Scout-App Classic
                "lin64": 0,    // Total count for all Linux 64-bit downloads of Scout-App Classic
                "osx": 82207   // Total count for all OSX downloads of Scout-App Classic
            }
        },
        "sa2": {
            "total": 8320,     // Total count for all downloads of Scout-App 2
            "osdist": {
                "win": 6439,   // Total count for all Windows downloads of Scout-App 2
                "lin32": 104,  // Total count for all Linux 32-bit downloads of Scout-App 2
                "lin64": 342,  // Total count for all Linux 64-bit downloads of Scout-App 2
                "osx": 1435    // Total count for all OSX downloads of Scout-App 2
            }
        }
    }
]
TheJaredWilcurt commented 7 years ago

Note: I originally wrote this issue as something that should be ran hourly, but in practice I don't see much utility that would be gained in hourly statistics. How many downloads per day is equally as useful and 1/24th the amount of bandwidth when loading the page. After 5 years the JSON payload would be 0.4MB for a daily check, versus 11.4MB for an hourly check. I wouldn't want to wait for 11 MBs to dowload on a phone just to see some stats. If this thing only gets as big as half a meg in 5 years, I think that's doable.

So anyways, daily stats, not hourly.