# Path: memsql_loader/util/super_json.py
# def simplejson_datetime_serializer(obj):
# def _set_defaults(kwargs):
# def dumps(data, **kwargs):
# def loads(data, **kwargs):
# def safe_loads(data, default, **kwargs):
# def pformat(d):
# 
# Path: memsql_loader/util/apsw_sql_step_queue/time_helpers.py
# def unix_timestamp(dt):
#     return int(time.mktime(dt.timetuple()))


import re
from datetime import datetime
from dateutil import parser
from clark.super_enum import SuperEnum
from memsql_loader.util import super_json as json
from memsql_loader.util.apsw_sql_step_queue.time_helpers import unix_timestamp
    @staticmethod
    def projection_params():
        return {
            'now': unix_timestamp(datetime.utcnow())
        }

class JobState(SuperEnum):
    QUEUED = SuperEnum.E
    RUNNING = SuperEnum.E
    FINISHED = SuperEnum.E
    CANCELLED = SuperEnum.E

    PROJECTION = re.sub(r'\s+', ' ', '''
        (CASE
            WHEN (
                (job_tasks.tasks_total - job_tasks.tasks_finished) = 0
                AND job_tasks.tasks_cancelled > 0) THEN 'CANCELLED'
            WHEN (
                job_tasks.tasks_total IS NULL
                OR job_tasks.tasks_finished = job_tasks.tasks_total) THEN 'FINISHED'
            WHEN (job_tasks.tasks_queued = job_tasks.tasks_total) THEN 'QUEUED'
            ELSE 'RUNNING'
        END)
    ''').strip()

class SortDirection(SuperEnum):
    DESC = SuperEnum.E
    ASC = SuperEnum.E

def task_load_row(row):

# Path: memsql_loader/util/super_json.py
# def simplejson_datetime_serializer(obj):
# def _set_defaults(kwargs):
# def dumps(data, **kwargs):
# def loads(data, **kwargs):
# def safe_loads(data, default, **kwargs):
# def pformat(d):
# 
# Path: memsql_loader/util/apsw_sql_step_queue/time_helpers.py
# def unix_timestamp(dt):
#     return int(time.mktime(dt.timetuple()))


# Path: memsql_loader/api/shared.py
import re
from datetime import datetime
from dateutil import parser
from clark.super_enum import SuperEnum
from memsql_loader.util import super_json as json
from memsql_loader.util.apsw_sql_step_queue.time_helpers import unix_timestamp

    @staticmethod
    def projection_params():
        return {
            'now': unix_timestamp(datetime.utcnow())
        }

class JobState(SuperEnum):
    QUEUED = SuperEnum.E
    RUNNING = SuperEnum.E
    FINISHED = SuperEnum.E
    CANCELLED = SuperEnum.E

    PROJECTION = re.sub(r'\s+', ' ', '''
        (CASE
            WHEN (
                (job_tasks.tasks_total - job_tasks.tasks_finished) = 0
                AND job_tasks.tasks_cancelled > 0) THEN 'CANCELLED'
            WHEN (
                job_tasks.tasks_total IS NULL
                OR job_tasks.tasks_finished = job_tasks.tasks_total) THEN 'FINISHED'
            WHEN (job_tasks.tasks_queued = job_tasks.tasks_total) THEN 'QUEUED'
            ELSE 'RUNNING'
        END)
    ''').strip()

class SortDirection(SuperEnum):
    DESC = SuperEnum.E
    ASC = SuperEnum.E

def task_load_row(row):

    row['data'] = json.safe_loads(row.data or '', {})