Code Monkey home page Code Monkey logo

prodplanner's Introduction

prodplanner

Django DRF project to calculate dates for recurrent actions

Based on dateutil ; it is possible to define rrules and dates and create rrulesets including or excluding rrulesets, rrules or datetimes.

The first goal is to get a list of dates, not datetimes.

To perform it :

  • rrules are defined at '/planner/simplerules/',
  • dates at '/planner/daterules/'
  • rrulesets at '/planner/rulesets/'
  • including or excluding elements from a rruleset at '/planner/rulesetelements/'

it is then possible to query a rruleset to get occurences on a time interval :

http://localhost:8000/planner/rulesets/886ac04c-d57f-4f1b-ab3d-f8415f5e0521/between/?start=2017-01-01T00:00:00&end=2018-01-01T00:00:00

HTTP 200 OK
Allow: GET, OPTIONS
Content-Type: application/json
Vary: Accept

[

    "2017-01-01",
    "2017-04-17",
    "2017-05-01",
    "2017-05-08",
    "2017-05-26",
    "2017-06-05",
    "2017-07-14",
    "2017-08-15",
    "2017-11-01",
    "2017-11-11",
    "2017-12-25",
    "2018-01-01"
]

It is also possible to get next 10 occurences for a ruleset :

http://localhost:8000/planner/rulesets/886ac04c-d57f-4f1b-ab3d-f8415f5e0521/next10/

[
    "2017-05-01",
    "2017-05-08",
    "2017-05-26",
    "2017-06-05",
    "2017-07-14",
    "2017-08-15",
    "2017-11-01",
    "2017-11-11",
    "2017-12-25",
    "2018-01-01"
]

python manage.py makemigrations

python manage.py migrate

Load fixtures : python manage.py loaddata fixtures/planner.json

The second goal is to schedule tasks To create a schedule you must select a ruleset and a delta which is based on dateutil.relativedelta and then choose the daytime (hour, minute, second) delta configuration is accessible at http://localhost:8000/planner/deltas/

A task will be generated for each occurence in the ruleset. The task will have the "due_time" datetime set to the date of the ruleset occurence with the time of the day chosen in the schedule. The start of the task will be calculated from the due_time plus the dateutil.relativedelta calculated from the delta object associated in the schedule (which should be negative).

Via django shell it is possible to generate tasks with :

import datetime
start = datetime.datetime(2017,4,25)
end = datetime.datetime(2018,4,25)
s = Schedule.objects.get(id='uuid-xxx-xxx-xxx')
from planner.models import schedule_models
schedule_models.task_generate(s, start, end)

version

Alpha developpement

tested with

  • Python 3.5.3
  • Django 1.11.1

todo

  • make it as a library or django-app
  • be able to change date of a task (without be regenerated by task_generate)
  • manage timezones
  • check for a task due_time to be after start
  • ... suggestions welcomed

prodplanner's People

Contributors

alehenaff avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.