# Path: pytorque/models.py
# class PBSServer(models.Model):
#     time = models.DateTimeField(
#         default=datetime.now)#auto_now_add=True sets datetime with creating object, not with every modifying action
# 
#     name = models.CharField(max_length=100)
#     state = models.CharField(max_length=20)
#     total_jobs = models.IntegerField()
#     running_jobs = models.IntegerField()
#     queued_jobs = models.IntegerField()
#     pbs_version = models.CharField(max_length=10)
# 
# class PBSUserStat(models.Model):
#     time = models.DateTimeField(default=datetime.now, auto_now_add=True)
# 
#     username = models.CharField(default='', max_length=100, blank=True, null=True)
#     jobCount = models.IntegerField(default=0, blank=True, null=True)


from datetime import timedelta, datetime
from chartit import DataPool, Chart
from pytorque.models import PBSServer, PBSUserStat
import time
            series_options=
            [{'options': {
                'type': 'line',
                'stacking': False},
              'terms': {
                  'time': [
                      'running_jobs',
                      'queued_jobs',
                      'total_jobs']
              }}],
            chart_options=
                {'title': {
                'text': title},
                 'xAxis': {
                     'title': {
                         'text': 'Time'}}},
            x_sortf_mapf_mts=(None, lambda i: datetime.fromtimestamp(i).strftime("%H:%M"), False))

        return chart

    @staticmethod
    def getUserStatChart(title, currentTime):
        try:
            lastUserStatTime = PBSUserStat.objects.latest('time').time
        except Exception as exc:
            lastUserStatTime = datetime.now()

        statistics = DataPool(
            series=
            [{'options': {

# Path: pytorque/models.py
# class PBSServer(models.Model):
#     time = models.DateTimeField(
#         default=datetime.now)#auto_now_add=True sets datetime with creating object, not with every modifying action
# 
#     name = models.CharField(max_length=100)
#     state = models.CharField(max_length=20)
#     total_jobs = models.IntegerField()
#     running_jobs = models.IntegerField()
#     queued_jobs = models.IntegerField()
#     pbs_version = models.CharField(max_length=10)
# 
# class PBSUserStat(models.Model):
#     time = models.DateTimeField(default=datetime.now, auto_now_add=True)
# 
#     username = models.CharField(default='', max_length=100, blank=True, null=True)
#     jobCount = models.IntegerField(default=0, blank=True, null=True)


# Path: pytorque/libs/charts.py
from datetime import timedelta, datetime
from chartit import DataPool, Chart
from pytorque.models import PBSServer, PBSUserStat
import time

            series_options=
            [{'options': {
                'type': 'line',
                'stacking': False},
              'terms': {
                  'time': [
                      'running_jobs',
                      'queued_jobs',
                      'total_jobs']
              }}],
            chart_options=
                {'title': {
                'text': title},
                 'xAxis': {
                     'title': {
                         'text': 'Time'}}},
            x_sortf_mapf_mts=(None, lambda i: datetime.fromtimestamp(i).strftime("%H:%M"), False))

        return chart

    @staticmethod
    def getUserStatChart(title, currentTime):
        try:
            lastUserStatTime = PBSUserStat.objects.latest('time').time
        except Exception as exc:
            lastUserStatTime = datetime.now()

        statistics = DataPool(
            series=
            [{'options': {

                'source': PBSUserStat.objects.filter(