euscan-ng/euscanwww/euscan/models.py
Corentin Chary 54f7771b43 euscanwww: add new charts
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
2011-05-03 08:19:01 +02:00

114 lines
4.4 KiB
Python

from django.db import models
class Herd(models.Model):
herd = models.CharField(max_length=128, unique=True)
email = models.CharField(max_length=128, blank=True, null=True)
def __unicode__(self):
if self.email:
return '%s <%s>' % (self.herd, self.email)
return self.herd
class Maintainer(models.Model):
name = models.CharField(max_length=128)
email = models.CharField(max_length=128, unique=True)
def __unicode__(self):
return '%s <%s>' % (self.name, self.email)
class Package(models.Model):
category = models.CharField(max_length=128)
name = models.CharField(max_length=128)
description = models.TextField(blank=True)
homepage = models.CharField(max_length=256, blank=True)
herds = models.ManyToManyField(Herd, blank=True)
maintainers = models.ManyToManyField(Maintainer, blank=True)
# For performance, we keep pre-computed counters
n_versions = models.IntegerField(default=0)
n_packaged = models.IntegerField(default=0)
n_overlay = models.IntegerField(default=0)
def __unicode__(self):
return '%s/%s' % (self.category, self.name)
class Meta:
unique_together = ['category', 'name']
class Version(models.Model):
package = models.ForeignKey(Package)
slot = models.CharField(max_length=128)
revision = models.CharField(max_length=128)
version = models.CharField(max_length=128)
packaged = models.BooleanField()
overlay = models.CharField(max_length=128, default='gentoo')
urls = models.TextField(blank=True)
def __unicode__(self):
return '%s/%s-%s-%s:%s [%s]' % (self.package.category, self.package.name,
self.version, self.revision, self.slot,
self.overlay)
class Meta:
unique_together = ['package', 'slot', 'revision', 'version', 'overlay']
class EuscanResult(models.Model):
package = models.ForeignKey(Package)
datetime = models.DateTimeField()
result = models.TextField(blank=True)
# Keep data for charts
class CategoryLog(models.Model):
category = models.CharField(max_length=128)
datetime = models.DateTimeField()
n_packages_gentoo = models.IntegerField(default=0) # Packages up to date in the main portage tree
n_packages_overlay = models.IntegerField(default=0) # Packages up to date in an overlay
n_packages_outdated = models.IntegerField(default=0) # Packages outdated
n_versions_gentoo = models.IntegerField(default=0) # Versions in the main portage tree
n_versions_overlay = models.IntegerField(default=0) # Versions in overlays
n_versions_upstream = models.IntegerField(default=0) # Upstream versions, not in the main tree or overlays
def __unicode__(self):
return u'%s [%d:%d:%d] [%d:%d:%d]' % \
(self.category, self.n_packages_gentoo, self.n_packages_overlay, self.n_packages_outdated, \
self.n_versions_gentoo, self.n_versions_overlay, self.n_versions_upstream)
class HerdLog(models.Model):
herd = models.ForeignKey(Herd)
datetime = models.DateTimeField()
n_packages_gentoo = models.IntegerField(default=0)
n_packages_overlay = models.IntegerField(default=0)
n_packages_outdated = models.IntegerField(default=0)
n_versions_gentoo = models.IntegerField(default=0)
n_versions_overlay = models.IntegerField(default=0)
n_versions_upstream = models.IntegerField(default=0)
def __unicode__(self):
return u'%s [%d:%d:%d] [%d:%d:%d]' % \
(self.herd, self.n_packages_gentoo, self.n_packages_overlay, self.n_packages_outdated, \
self.n_versions_gentoo, self.n_versions_overlay, self.n_versions_upstream)
class MaintainerLog(models.Model):
maintainer = models.ForeignKey(Maintainer)
datetime = models.DateTimeField()
n_packages_gentoo = models.IntegerField(default=0)
n_packages_overlay = models.IntegerField(default=0)
n_packages_outdated = models.IntegerField(default=0)
n_versions_gentoo = models.IntegerField(default=0)
n_versions_overlay = models.IntegerField(default=0)
n_versions_upstream = models.IntegerField(default=0)
def __unicode__(self):
return u'%s [%d:%d:%d] [%d:%d:%d]' % \
(self.maintainer, self.n_packages_gentoo, self.n_packages_overlay, self.n_packages_outdated, \
self.n_versions_gentoo, self.n_versions_overlay, self.n_versions_upstream)