Taskenizer

Check-in [84776badf3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fix bug with notes not undefering
Timelines: family | ancestors | coming_up
Files: files | file ages | folders
SHA1: 84776badf36c955db17ce7276a86d286436ca472
User & Date: joseph 2020-02-19 10:06:36
Context
2020-02-19
10:06
fix bug with notes not undefering Leaf check-in: 84776badf3 user: joseph tags: coming_up
2019-12-15
16:10
Made it use mysql instead of SQLITE check-in: e2ebb78c9c user: joseph tags: coming_up
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to doc/regression_tests.

297
298
299
300
301
302
303







- make sure it doesn't try to start if it's already started
- make sure it doesn't try to stop if it's not running
- make sure it doesn't try to restart if it's not running

- make sure it checks it has read-write access to shmdir and
  user_locks before it starts













>
>
>
>
>
>
297
298
299
300
301
302
303
304
305
306
307
308
309

- make sure it doesn't try to start if it's already started
- make sure it doesn't try to stop if it's not running
- make sure it doesn't try to restart if it's not running

- make sure it checks it has read-write access to shmdir and
  user_locks before it starts

- make cat shared between 2 users
- user b adds note
- user a moves that note into a non-shared category
- user a defers it
- does it come undeferred again?

Changes to taskenizer/functions/operations.py.

1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
    return next_nix_secs - userdiff


def un_defer_any(conn, cat_id, cur_time, user_id, foo_timezone, task_type):
    '''Will un-defer any due deferred tasks in that category. Will be
    run before displaying a category.'''

    tup = (cat_id, user_id)

    if task_type == 0:
        cat_type = 'Note'
    if task_type == 1:
        cat_type = 'AutoHabit'
    if task_type == 2:
        cat_type = 'ManuHabit'

    # Get all deferred tasks in this category
    conn.execute('''SELECT id, def_days, def_months,
                 def_years
                 FROM %s
                 WHERE cat_id = %%s
                 AND user_id = %%s
                 AND deferred = 1;''' % cat_type, tup)
    def_tasks = conn.fetchall()

    for task in def_tasks:
        tasid = task[0]
        days = task[1]
        months = task[2]
        years = task[3]

        time_due = when_due(cur_time, foo_timezone, days, months, years)

        # If that's before now, un-defer it
        if time_due <= cur_time:
            tup = (tasid, user_id)

            # Note that it doesn't clear the `next_days',
            # `next_months' etc values.
            conn.execute('''UPDATE %s SET deferred = 0
                         WHERE id = %%s
                         AND user_id = %%s''' % cat_type, tup)


def cookie_auth(cook):
    """Checks for three auth cookies. If all of them are present, returns them.

    The first element of the tuple is always 0 for all cookies found or 1 otherwize.
    """







|













<













|




<
|







1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275

1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293

1294
1295
1296
1297
1298
1299
1300
1301
    return next_nix_secs - userdiff


def un_defer_any(conn, cat_id, cur_time, user_id, foo_timezone, task_type):
    '''Will un-defer any due deferred tasks in that category. Will be
    run before displaying a category.'''

    tup = (cat_id,)

    if task_type == 0:
        cat_type = 'Note'
    if task_type == 1:
        cat_type = 'AutoHabit'
    if task_type == 2:
        cat_type = 'ManuHabit'

    # Get all deferred tasks in this category
    conn.execute('''SELECT id, def_days, def_months,
                 def_years
                 FROM %s
                 WHERE cat_id = %%s

                 AND deferred = 1;''' % cat_type, tup)
    def_tasks = conn.fetchall()

    for task in def_tasks:
        tasid = task[0]
        days = task[1]
        months = task[2]
        years = task[3]

        time_due = when_due(cur_time, foo_timezone, days, months, years)

        # If that's before now, un-defer it
        if time_due <= cur_time:
            tup = (tasid,)

            # Note that it doesn't clear the `next_days',
            # `next_months' etc values.
            conn.execute('''UPDATE %s SET deferred = 0

                         WHERE id = %%s''' % cat_type, tup)


def cookie_auth(cook):
    """Checks for three auth cookies. If all of them are present, returns them.

    The first element of the tuple is always 0 for all cookies found or 1 otherwize.
    """