89:f0859c756b62 0.4.1
Anton Shestakov <av6@dwimlabs.net>, Thu, 26 May 2016 01:01:27 +0800
docs: update What's New for 0.4.1

next change 96:5e7f52c8da36
previous change 7:5c5d433b3a14

fruitbar/indexes.py

Permissions: -rw-r--r--

Other formats: Feeds:
#-*- coding:utf-8 -*-
from hashlib import md5
from CodernityDB.hash_index import HashIndex
class ProjectIndex(HashIndex):
def __init__(self, *args, **kwargs):
kwargs['key_format'] = '16s'
super(ProjectIndex, self).__init__(*args, **kwargs)
def make_key_value(self, data):
if data['_t'] == 'project':
return md5(data['workspace'].encode('utf-8')).digest(), None
def make_key(self, key):
return md5(key).digest()
class TaskIndex(HashIndex):
def __init__(self, *args, **kwargs):
kwargs['key_format'] = '16s'
super(TaskIndex, self).__init__(*args, **kwargs)
def make_key_value(self, data):
if data['_t'] == 'task':
return md5(data['workspace'].encode('utf-8')).digest(), None
def make_key(self, key):
return md5(key).digest()
def run_delete_for_project(self, db, workspace, project_id):
for task in db.get_many('task', workspace, with_doc=True):
if task['doc']['project_id'] == project_id:
db.delete(task['doc'])