10baa0c935d9646be4c9c797fc9d0ae40e9637a2
[laas.git] / src / analytics / models.py
1 ##############################################################################
2 # Copyright (c) 2020 Sean Smith and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 from django.db import models
11 from account.models import Lab
12
13
14 class ActiveVPNUser(models.Model):
15     """ Keeps track of how many VPN Users are connected to Lab """
16     time_stamp = models.DateTimeField(auto_now_add=True)
17     lab = models.ForeignKey(Lab, on_delete=models.CASCADE, null=False)
18     active_users = models.IntegerField()
19
20     @classmethod
21     def create(cls, lab_name, active_users):
22         """
23         This creates an Active VPN Users entry from
24         from lab_name as a string
25         """
26
27         lab = Lab.objects.get(name=lab_name)
28         avu = cls(lab=lab, active_users=active_users)
29         avu.save()
30         return avu