Last active
August 3, 2016 09:32
-
-
Save ronfe/909b39279819f164098086b4a969f9ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "_id" : ObjectId("57a1b5040d1bce971242995a"), | |
| "videos" : { | |
| "201629" : { | |
| "list" : [ | |
| "54cc7835abc5bbb971f99be0", | |
| "54cc783eabc5bbb971f99be1", | |
| "54d300a49ca3a7f10f5e84ad", | |
| "54d1ee8393ada5bf333e9e8b", | |
| "54d304139ca3a7f10f5e868b", | |
| "54d305fb9ca3a7f10f5e8801", | |
| "565fe85f57da889d4091615c", | |
| "54d313389ca3a7f10f5e90f9", | |
| "565febaf57da889d40916194", | |
| "54cc776dabc5bbb971f99bd4", | |
| "54d316a99ca3a7f10f5e92a5", | |
| "54d3189e9ca3a7f10f5e9468" | |
| ], | |
| "pv" : 38 | |
| } | |
| }, | |
| "type" : "device", | |
| "activatedWeeks" : [ | |
| "201629" | |
| ], | |
| "semester" : "undefined", | |
| "practices" : { | |
| "201629" : { | |
| "list" : [ | |
| "54c708798bac81fccbd4bbd5", | |
| "54c708798bac81fccbd4bbd8", | |
| "565fe7f057da889d40916159", | |
| "54c708798bac81fccbd4bbdc", | |
| "565fe7f157da889d4091615a", | |
| "54cc776dabc5bbb971f99bd4", | |
| "54c708798bac81fccbd4bbe6" | |
| ], | |
| "pv" : 10 | |
| } | |
| }, | |
| "role" : "student", | |
| "from" : "android", | |
| "id" : "000000357900265", | |
| "activationWeek" : "201629" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| cur = datetime.datetime.now() | |
| print(cur) | |
| x = cur.strftime("%Y%W") | |
| print(x) | |
| y = "201619" | |
| x = datetime.datetime.strptime(y, "%Y%W") | |
| print(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pymongo import MongoClient | |
| db = MongoClient('10.8.8.111:27017')['ronfedb']['weeklyCache'] | |
| user_weekly_cache_schema = { | |
| "id": str, #id of the account, "_id" for user, "device" for device | |
| "type": str, #type of the account, "user" for registrated users, "device" for activated devices | |
| "activationWeek": str, #Week of registration/activation date formatted by %Y%W | |
| "activatedWeeks": [str], #List of weeks of being active formatted by %Y%W | |
| "semester": str, #"unknown" for device account, and actual semester for user account (default "七年级上") | |
| "role": str, #"student" for device account, and actual role for user account | |
| "from": str, #os for device account, and actual from for user account | |
| "hasRoom": bool, # only user has this field, True if a user had joined at least one room | |
| "videos": { | |
| "201619": { #key is the week formatted by %Y%W | |
| "pv": int, #PV of startVideo by that user in that week since 3.5 | |
| "list": [str] #List of the string video id started by that user in that week since 3.5 | |
| } | |
| }, | |
| "practices": { | |
| "201619": { #key is the week formatted by %Y%W | |
| "pv": int, #PV of startPractice by that user in that week since 3.5 | |
| "list": [str] #List of the string topic id started by that user in that week since 3.5 | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment