Skip to content

Commit

Permalink
add usage thin usage stat for metalab projects
Browse files Browse the repository at this point in the history
  • Loading branch information
luto committed Mar 9, 2024
1 parent 6a7acb0 commit cf1d3a0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/THINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $ curl https://metalab.at/things/usage/prusaxl -H "X-TOKEN: XXX" -XPOST -d 'user
* `LOGOUT`, user stopped using a machine
* `USAGE_MEMBER`, user used the machine for X seconds, for a member
* `USAGE_NONMEMBER`, user used the machine for X seconds, for a non-member
* `USAGE_METALAB`, user used the machine for X seconds, for a metalab infra project

Additionally, supply `usage_seconds=` as an integer for `USAGE_` kinds.

Expand Down
19 changes: 19 additions & 0 deletions things/migrations/0008_alter_thingevent_kind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.20 on 2024-03-09 21:15

from django.db import migrations
from django.db import models


class Migration(migrations.Migration):

dependencies = [
('things', '0007_alter_thingevent_usage_seconds'),
]

operations = [
migrations.AlterField(
model_name='thingevent',
name='kind',
field=models.CharField(choices=[('LOGIN', 'Login'), ('LOGOUT', 'Logout'), ('USAGE_MEMBER', 'Zeit (Member)'), ('USAGE_NONMEMBER', 'Zeit (Nicht-Member)'), ('USAGE_METALAB', 'Zeit (für Metalab)')], db_index=True, max_length=32),
),
]
1 change: 1 addition & 0 deletions things/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Kind(models.TextChoices):
LOGOUT = ("LOGOUT", "Logout")
USAGE_MEMBER = ("USAGE_MEMBER", "Zeit (Member)")
USAGE_NONMEMBER = ("USAGE_NONMEMBER", "Zeit (Nicht-Member)")
USAGE_METALAB = ("USAGE_METALAB", "Zeit (für Metalab)")

thing = models.ForeignKey(Thing, on_delete=models.PROTECT)
user = models.ForeignKey(
Expand Down

0 comments on commit cf1d3a0

Please sign in to comment.