NosotrosNueces / utcs-uptime

Let's keep a database of everybody's uptime!
https://nosotrosnueces.github.io/utcs-uptime/
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Hook up to a database #3

Closed jeversmann closed 9 years ago

jeversmann commented 9 years ago

We need a database to store usage times. I don't know how NoSQL works, but I want to be able to store numbers associated with a user and server, so we can select and sum across computers/people. I would propose a schema, but I think that's already missing the point.

jeversmann commented 9 years ago

My suggestion, as posted in my mongo-time branch:

Current holds the last seen state of each host:

{
  "hostname": "string",
  "physical": "boolean",
  "user-count": "int",
  "users": [
    {
      "name": "string",
      "tty": "string",
      "from": "string",
      "time": "date"
    }
  ]
}

physical could be calculated later by filtering across users, but this will let us select over it. Storing multiple users with the same name will be confusing, so we should try to keep only the longest running session per user/machine pair.

Session holds a doc for each recorded user session":

{
  "username": "string",
  "servername": "string",
  "hostname": "string",
  "time": "date",
  "physical": "boolean"
}

hostname is carried over from user[from] above; we probably shouldn"t do anything with it, but we have access to it. As with before, physical could be extracted from hostname, but having it is nice.

JDongian commented 9 years ago

If you want a sort of schema, check out mongoose. I think the idea here is good. I want the raw data stored, and the client to do computation.

jeversmann commented 9 years ago

I'm starting to want modifications to the original proposal already.

  1. The fields that hold the same information should have the same names in every object.
  2. Rather than a single time field on session, I want a login time and logout time.
  3. It would be cool to have the load average information in the current objects, which requires some change to how who.read runs.
  4. A last updated time stamp for current.
jeversmann commented 9 years ago

Also worth noting, attribute names should be valid with dot syntax, and user-count is not.