This file contains hidden or 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
from django.db import models | |
class Visualization(models.Model): | |
name = models.CharField(primary_key=True, max_length=200) | |
description = models.TextField() | |
position = models.IntegerField(default=200) | |
def __repr__ (self): | |
return self.name |
This file contains hidden or 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
from visualizations.models import Visualization | |
class InfectionRateVisualization(Visualization): | |
class Meta: | |
proxy = True | |
def from_data(csvfile): | |
department_instances = [] | |
infection_type = [] |
This file contains hidden or 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
from django.db import models | |
class Visualization(models.Model): | |
name = models.CharField(primary_key=True, max_length=200) | |
description = models.TextField() | |
position = models.IntegerField(default=200) | |
class = models.CharField(max_length=200) #We just added this line | |
... |
This file contains hidden or 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
from __future__ import unicode_literals | |
from django.shortcuts import render | |
from models import Visualization | |
from exceptions import IncompleteDataException | |
from .forms import VisualizationForm | |
from django.contrib.auth.decorators import login_required | |
def _inject_visualization(name): | |
if name == "infection_rate_visualization": |
This file contains hidden or 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
from __future__ import unicode_literals | |
from django.shortcuts import render | |
from models import Visualization | |
from exceptions import IncompleteDataException | |
from .forms import VisualizationForm | |
from django.contrib.auth.decorators import login_required | |
VISUALIZATIONS = { | |
"infection_rate_visualization": InfectionRateVisualization.objects.get(pk="infection_rate_visualization"), |
This file contains hidden or 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
from __future__ import unicode_literals | |
from django.shortcuts import render | |
from models import Visualization | |
from exceptions import IncompleteDataException, ConstantizeException | |
from .forms import VisualizationForm | |
from django.contrib.auth.decorators import login_required | |
import inspect, re |
This file contains hidden or 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
import numpy as np | |
import pandas as pd | |
import sklearn | |
import nltk | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
class Content(): | |
_cached_data = None | |
This file contains hidden or 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
class Import | |
def import_workouts(rows) | |
errors = [] | |
CSV.foreach(@import_file_path, {headers: true}) do |row| | |
begin | |
attributes = row.to_hash | |
row.create(attributes) | |
errors += row.failures |
This file contains hidden or 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
class Import | |
def import_workouts(rows) | |
CSV.foreach(@import_file_path, {headers: true}) do |row| | |
attributes = row.to_hash | |
workout = Workout.new(attributes) | |
unless workout.save | |
workout.save(validate: false) | |
workout.update_column(:status, :needs_revision) |
This file contains hidden or 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
class Workout | |
property :description, type: String | |
property :date, type: DateTime | |
enum status: [:needs_revision, :complete] | |
property :status, default: :complete | |
scope :complete, -> { where(status: :complete) } | |
scope :needs_revision, -> { where(status: :needs_revision) } | |