aboutsummaryrefslogtreecommitdiffstats
path: root/src/analytics
diff options
context:
space:
mode:
Diffstat (limited to 'src/analytics')
-rw-r--r--src/analytics/__init__.py0
-rw-r--r--src/analytics/admin.py13
-rw-r--r--src/analytics/apps.py14
-rw-r--r--src/analytics/migrations/0001_initial.py22
-rw-r--r--src/analytics/migrations/0002_auto_20201109_2149.py27
-rw-r--r--src/analytics/migrations/__init__.py0
-rw-r--r--src/analytics/models.py30
-rw-r--r--src/analytics/tests.py10
-rw-r--r--src/analytics/views.py10
9 files changed, 126 insertions, 0 deletions
diff --git a/src/analytics/__init__.py b/src/analytics/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/analytics/__init__.py
diff --git a/src/analytics/admin.py b/src/analytics/admin.py
new file mode 100644
index 0000000..63f139f
--- /dev/null
+++ b/src/analytics/admin.py
@@ -0,0 +1,13 @@
+##############################################################################
+# 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.contrib import admin
+from analytics.models import ActiveVPNUser
+
+admin.site.register(ActiveVPNUser)
diff --git a/src/analytics/apps.py b/src/analytics/apps.py
new file mode 100644
index 0000000..fe1b11f
--- /dev/null
+++ b/src/analytics/apps.py
@@ -0,0 +1,14 @@
+##############################################################################
+# 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.apps import AppConfig
+
+
+class AnalyticsConfig(AppConfig):
+ name = 'analytics'
diff --git a/src/analytics/migrations/0001_initial.py b/src/analytics/migrations/0001_initial.py
new file mode 100644
index 0000000..05a7ec8
--- /dev/null
+++ b/src/analytics/migrations/0001_initial.py
@@ -0,0 +1,22 @@
+# Generated by Django 2.2 on 2020-08-10 20:10
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='ActiveVPNUsers',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('time_stamp', models.DateTimeField(auto_now_add=True)),
+ ('active_users', models.IntegerField()),
+ ],
+ ),
+ ]
diff --git a/src/analytics/migrations/0002_auto_20201109_2149.py b/src/analytics/migrations/0002_auto_20201109_2149.py
new file mode 100644
index 0000000..a845ff8
--- /dev/null
+++ b/src/analytics/migrations/0002_auto_20201109_2149.py
@@ -0,0 +1,27 @@
+# Generated by Django 2.2 on 2020-11-09 21:49
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('account', '0006_auto_20201109_1947'),
+ ('analytics', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='ActiveVPNUser',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('time_stamp', models.DateTimeField(auto_now_add=True)),
+ ('active_users', models.IntegerField()),
+ ('lab', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='account.Lab')),
+ ],
+ ),
+ migrations.DeleteModel(
+ name='ActiveVPNUsers',
+ ),
+ ]
diff --git a/src/analytics/migrations/__init__.py b/src/analytics/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/analytics/migrations/__init__.py
diff --git a/src/analytics/models.py b/src/analytics/models.py
new file mode 100644
index 0000000..10baa0c
--- /dev/null
+++ b/src/analytics/models.py
@@ -0,0 +1,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
diff --git a/src/analytics/tests.py b/src/analytics/tests.py
new file mode 100644
index 0000000..d234f48
--- /dev/null
+++ b/src/analytics/tests.py
@@ -0,0 +1,10 @@
+##############################################################################
+# 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.test import TestCase
diff --git a/src/analytics/views.py b/src/analytics/views.py
new file mode 100644
index 0000000..160bc59
--- /dev/null
+++ b/src/analytics/views.py
@@ -0,0 +1,10 @@
+##############################################################################
+# 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.shortcuts import render