Skip to content

Instantly share code, notes, and snippets.

@ronfe
Last active August 3, 2016 09:32
Show Gist options
  • Select an option

  • Save ronfe/909b39279819f164098086b4a969f9ce to your computer and use it in GitHub Desktop.

Select an option

Save ronfe/909b39279819f164098086b4a969f9ce to your computer and use it in GitHub Desktop.
{
"_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"
}
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)
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