aboutsummaryrefslogtreecommitdiffstats
path: root/src/analytics/models.py
blob: 10baa0c935d9646be4c9c797fc9d0ae40e9637a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
##############################################################################
# Copyright (c) 2020 Sean Smith and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

from django.db import models
from account.models import Lab


class ActiveVPNUser(models.Model):
    """ Keeps track of how many VPN Users are connected to Lab """
    time_stamp = models.DateTimeField(auto_now_add=True)
    lab = models.ForeignKey(Lab, on_delete=models.CASCADE, null=False)
    active_users = models.IntegerField()

    @classmethod
    def create(cls, lab_name, active_users):
        """
        This creates an Active VPN Users entry from
        from lab_name as a string
        """

        lab = Lab.objects.get(name=lab_name)
        avu = cls(lab=lab, active_users=active_users)
        avu.save()
        return avu