-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
85 changed files
with
11,301 additions
and
862 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
exclude_paths: | ||
- "docs/*" | ||
- "tally_ho/libs/*" | ||
- "tally_ho/apps/tally/static/js/data_table.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tally_ho/apps/tally/migrations/0034_quarantinecheck_description.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.1.1 on 2020-11-13 07:13 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('tally', '0033_auto_20201028_1543'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='quarantinecheck', | ||
name='description', | ||
field=models.TextField(blank=True, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 2.1.1 on 2020-12-06 07:09 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('tally', '0034_quarantinecheck_description'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='quarantinecheck', | ||
name='percentage', | ||
field=models.FloatField(default=0), | ||
), | ||
migrations.AlterField( | ||
model_name='quarantinecheck', | ||
name='value', | ||
field=models.FloatField(default=0), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Generated by Django 2.1.1 on 2021-02-01 13:45 | ||
|
||
import django.contrib.postgres.fields | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('tally', '0035_auto_20201206_0709'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='AllCandidatesVotes', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('tally_id', models.IntegerField()), | ||
('full_name', models.CharField(max_length=255)), | ||
('ballot_number', models.IntegerField()), | ||
('candidate_id', models.IntegerField()), | ||
('candidate_active', models.BooleanField(default=False)), | ||
('stations', models.PositiveIntegerField(default=0)), | ||
('center_ids', django.contrib.postgres.fields.ArrayField( | ||
base_field=models.IntegerField(), size=None)), | ||
('station_numbers', django.contrib.postgres.fields.ArrayField(base_field=models.PositiveSmallIntegerField(blank=True, null=True), size=None)), | ||
('stations_completed', models.PositiveIntegerField(default=0)), | ||
('votes', models.PositiveIntegerField(default=0)), | ||
('total_votes', models.PositiveIntegerField(default=0)), | ||
('all_candidate_votes', models.PositiveIntegerField(default=0)), | ||
('candidate_votes_included_quarantine', models.PositiveIntegerField(default=0)), | ||
('stations_complete_percent', models.IntegerField()), | ||
], | ||
options={ | ||
'managed': False, | ||
}, | ||
), | ||
migrations.RunSQL( | ||
""" | ||
CREATE MATERIALIZED VIEW tally_allcandidatesvotes AS | ||
SELECT "tally_candidate"."full_name", "tally_candidate"."tally_id" AS "tally_id", "tally_candidate"."id" AS "candidate_id", "tally_ballot"."number" AS "ballot_number", "tally_candidate"."active" AS "candidate_active", COUNT("tally_resultform"."id") FILTER (WHERE ("tally_resultform"."ballot_id" IS NOT NULL AND "tally_resultform"."center_id" IS NOT NULL AND "tally_resultform"."station_number" IS NOT NULL AND "tally_resultform"."tally_id" = ("tally_candidate"."tally_id"))) AS "stations", COUNT("tally_resultform"."id") FILTER (WHERE ("tally_resultform"."ballot_id" IS NOT NULL AND "tally_resultform"."center_id" IS NOT NULL AND "tally_resultform"."form_state" = 0 AND "tally_resultform"."station_number" IS NOT NULL AND "tally_resultform"."tally_id" = ("tally_candidate"."tally_id"))) AS "stations_completed", (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND U3."form_state" = 0) LIMIT 1) AS "votes", CASE WHEN (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND U3."form_state" = 0) LIMIT 1) IS NOT NULL THEN (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND U3."form_state" = 0) LIMIT 1) ELSE 0 END AS "total_votes", (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND (U3."form_state" = 0 OR U3."form_state" = 2)) LIMIT 1) AS "all_candidate_votes", CASE WHEN (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND (U3."form_state" = 0 OR U3."form_state" = 2)) LIMIT 1) IS NOT NULL THEN (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND (U3."form_state" = 0 OR U3."form_state" = 2)) LIMIT 1) ELSE 0 END AS "candidate_votes_included_quarantine", CASE WHEN COUNT("tally_resultform"."id") FILTER (WHERE ("tally_resultform"."ballot_id" IS NOT NULL AND "tally_resultform"."center_id" IS NOT NULL AND "tally_resultform"."station_number" IS NOT NULL AND "tally_resultform"."tally_id" = ("tally_candidate"."tally_id"))) > 0 THEN ROUND(CAST(((100 * CAST(COUNT("tally_resultform"."id") FILTER (WHERE ("tally_resultform"."ballot_id" IS NOT NULL AND "tally_resultform"."center_id" IS NOT NULL AND "tally_resultform"."form_state" = 0 AND "tally_resultform"."station_number" IS NOT NULL AND "tally_resultform"."tally_id" = ("tally_candidate"."tally_id"))) AS FLOAT)) / CAST(COUNT("tally_resultform"."id") FILTER (WHERE ("tally_resultform"."ballot_id" IS NOT NULL AND "tally_resultform"."center_id" IS NOT NULL AND "tally_resultform"."station_number" IS NOT NULL AND "tally_resultform"."tally_id" = ("tally_candidate"."tally_id"))) AS FLOAT)) AS numeric), 3) ELSE 0 END AS "stations_complete_percent", ARRAY_AGG(DISTINCT "tally_center"."id") AS "center_ids", ARRAY_AGG(DISTINCT "tally_resultform"."station_number") AS "station_numbers" FROM "tally_candidate" INNER JOIN "tally_ballot" ON ("tally_candidate"."ballot_id" = "tally_ballot"."id") LEFT OUTER JOIN "tally_resultform" ON ("tally_ballot"."id" = "tally_resultform"."ballot_id") LEFT OUTER JOIN "tally_center" ON ("tally_resultform"."center_id" = "tally_center"."id") GROUP BY "tally_candidate"."id", "tally_ballot"."number", (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND U3."form_state" = 0) LIMIT 1), CASE WHEN (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND U3."form_state" = 0) LIMIT 1) IS NOT NULL THEN (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND U3."form_state" = 0) LIMIT 1) ELSE 0 END, (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND (U3."form_state" = 0 OR U3."form_state" = 2)) LIMIT 1), CASE WHEN (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND (U3."form_state" = 0 OR U3."form_state" = 2)) LIMIT 1) IS NOT NULL THEN (SELECT CASE WHEN U0."votes" IS NOT NULL THEN U0."votes" ELSE 0 END AS "candidate_votes" FROM "tally_result" U0 INNER JOIN "tally_candidate" U1 ON (U0."candidate_id" = U1."id") INNER JOIN "tally_resultform" U3 ON (U0."result_form_id" = U3."id") WHERE (U0."active" = true AND U0."candidate_id" = ("tally_candidate"."id") AND U1."tally_id" = ("tally_candidate"."tally_id") AND U0."entry_version" = 2 AND (U3."form_state" = 0 OR U3."form_state" = 2)) LIMIT 1) ELSE 0 END; | ||
CREATE UNIQUE INDEX tally_allcandidatesvotes_pk ON tally_allcandidatesvotes(candidate_id); | ||
""", | ||
""" | ||
DROP MATERIALIZED VIEW tally_allcandidatesvotes; | ||
""" | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django.db import models | ||
from django.contrib.postgres.fields import ArrayField | ||
|
||
import reversion | ||
|
||
|
||
class AllCandidatesVotes(models.Model): | ||
class Meta: | ||
app_label = 'tally' | ||
managed = False | ||
|
||
tally_id = models.IntegerField() | ||
full_name = models.CharField(max_length=255) | ||
ballot_number = models.IntegerField() | ||
candidate_id = models.IntegerField() | ||
candidate_active = models.BooleanField(default=False) | ||
stations = models.PositiveIntegerField(default=0) | ||
center_ids = ArrayField(models.IntegerField()) | ||
station_numbers = ArrayField(models.PositiveSmallIntegerField( | ||
blank=True, null=True)) | ||
stations_completed = models.PositiveIntegerField(default=0) | ||
votes = models.PositiveIntegerField(default=0) | ||
total_votes = models.PositiveIntegerField(default=0) | ||
all_candidate_votes = models.PositiveIntegerField(default=0) | ||
candidate_votes_included_quarantine = models.PositiveIntegerField( | ||
default=0) | ||
stations_complete_percent = models.IntegerField() | ||
|
||
|
||
reversion.register(AllCandidatesVotes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.