FUCKING BIG SYNC UPDATE: caching, events, albums, documents, awards, news, schedules, teachers, other
This commit is contained in:
1 parent
359cc430f5
commit
f07c39c317
20 files changed
+1190
-166
No files matched your search
@@ -1,14 +1,38 @@
|
||||
from sync.teacher import read_teacher_by_id
|
||||
from sync.image import sync_image
|
||||
from utils.fn import key_mapper
|
||||
from utils.text.transform import interpolate_swift
|
||||
|
||||
|
||||
def resolve_value(param, store):
|
||||
"""
|
||||
|
||||
:param param: \(nv-andreeva)
|
||||
:param store: function should return value by key nv-andreeva
|
||||
:return:
|
||||
"""
|
||||
i = interpolate_swift(param)
|
||||
return store(i)
|
||||
|
||||
|
||||
unpop_image = key_mapper('image', lambda i: sync_image(i)['_id'])
|
||||
|
||||
|
||||
|
||||
def resolve_teacher(i):
|
||||
return resolve_value(i, read_teacher_by_id)
|
||||
|
||||
|
||||
def create_product(doc):
|
||||
# author, image, title, awards, teacher, date
|
||||
|
||||
unpop_teacher = key_mapper('teacher', lambda i: i['_id'])
|
||||
|
||||
product = {**doc}
|
||||
unpop_image(product)
|
||||
|
||||
product['teacher'] = resolve_teacher(doc['teacher'])
|
||||
if(product['teacher']):
|
||||
unpop_teacher(product)
|
||||
|
||||
return product
|
||||
Reference in new issue
Block a user