Mixonomer/music/model/tag.py

37 lines
937 B
Python
Raw Normal View History

2020-04-30 14:54:05 +01:00
from fireo.models import Model
2022-12-10 08:44:27 +00:00
from fireo.fields import TextField, DateTime, NumberField, ListField, BooleanField, IDField
2020-02-03 09:44:33 +00:00
2020-04-30 14:54:05 +01:00
class Tag(Model):
class Meta:
collection_name = 'tags'
2020-02-03 09:44:33 +00:00
2022-12-10 08:44:27 +00:00
id = IDField()
2020-04-30 14:54:05 +01:00
tag_id = TextField(required=True)
name = TextField(required=True)
username = TextField(required=True)
2020-02-03 09:44:33 +00:00
2020-04-30 14:54:05 +01:00
tracks = ListField(default=[])
albums = ListField(default=[])
artists = ListField(default=[])
2020-02-03 09:44:33 +00:00
2020-04-30 14:54:05 +01:00
count = NumberField(default=0)
proportion = NumberField(default=0)
total_user_scrobbles = NumberField(default=0)
2020-02-03 09:44:33 +00:00
2020-04-30 14:54:05 +01:00
last_updated = DateTime()
2020-02-03 09:44:33 +00:00
2020-08-13 17:48:20 +01:00
time_objects = BooleanField(default=False)
total_time = TextField(default='00:00:00')
total_time_ms = NumberField(default=0)
2020-02-03 09:44:33 +00:00
def to_dict(self):
2020-04-30 14:54:05 +01:00
to_return = super().to_dict()
2020-02-03 09:44:33 +00:00
2020-04-30 14:54:05 +01:00
# remove unnecessary and sensitive fields
to_return.pop('id', None)
to_return.pop('key', None)
2020-02-03 09:44:33 +00:00
2020-04-30 14:54:05 +01:00
return to_return