git commit -m "Initial commit"
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import sys
|
||||
import os
|
||||
curPath = os.path.abspath(os.path.dirname(__file__))
|
||||
rootPath = os.path.split(curPath)[0]
|
||||
sys.path.append(rootPath)
|
||||
|
||||
|
||||
import common
|
||||
from common import configs as cfg
|
||||
from sync import utils
|
||||
|
||||
|
||||
prod_district_stat = common.get_mongodb_collection(cfg.MONGO_URI, "fangjia_stat", "district_stat")
|
||||
test_district_stat = common.get_mongodb_collection(cfg.TEST_URI, "fangjia_stat", "district_stat")
|
||||
for index in prod_district_stat.list_indexes():
|
||||
keys = list()
|
||||
for key in index["key"]:
|
||||
keys.append((key, index["key"][key]))
|
||||
print(index)
|
||||
if "unique" in index:
|
||||
test_district_stat.create_index(keys, background=True, unique=index["unique"])
|
||||
else:
|
||||
test_district_stat.create_index(keys, background=True)
|
||||
|
||||
for seaweed in utils.get_all_test_seaweed():
|
||||
sync_condition = {
|
||||
"city": seaweed["city"],
|
||||
"region": seaweed["region"],
|
||||
"district_name": seaweed["name"],
|
||||
"weekend": {"$gt": common.parse_date("2018-03-01")}
|
||||
}
|
||||
print(sync_condition)
|
||||
total = prod_district_stat.count(sync_condition)
|
||||
count = 0
|
||||
for dbo in prod_district_stat.find(sync_condition, no_cursor_timeout=True).batch_size(1000):
|
||||
count += 1
|
||||
test_district_stat.save(dbo)
|
||||
if count % 1000 == 0:
|
||||
print(str(count) + "/" + str(total))
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import common
|
||||
from common import configs as cfg
|
||||
|
||||
|
||||
prod_district_stat = common.get_mongodb_collection(cfg.MONGO_URI, "fangjia", "district_stat_rent")
|
||||
test_district_stat = common.get_mongodb_collection(cfg.TEST_URI, "fangjia", "district_stat_rent")
|
||||
for index in prod_district_stat.list_indexes():
|
||||
keys = list()
|
||||
for key in index["key"]:
|
||||
keys.append((key, index["key"][key]))
|
||||
print(index)
|
||||
if "unique" in index:
|
||||
test_district_stat.create_index(keys, background=True, unique=index["unique"])
|
||||
else:
|
||||
test_district_stat.create_index(keys, background=True)
|
||||
|
||||
|
||||
|
||||
sync_condition = {
|
||||
"city": "上海",
|
||||
"region": "长宁",
|
||||
"end_month_date": {"$gt": common.parse_date("2018-03-01")}
|
||||
}
|
||||
|
||||
total = prod_district_stat.count(sync_condition)
|
||||
count = 0
|
||||
for dbo in prod_district_stat.find(sync_condition, no_cursor_timeout=True).batch_size(1000):
|
||||
count += 1
|
||||
test_district_stat.save(dbo)
|
||||
if count % 1000 == 0:
|
||||
print(str(count) + "/" + str(total))
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
import common
|
||||
seaweed = common.get_mongodb_collection("mongodb://192.168.0.39:52002/", "fangjia", "seaweed")
|
||||
|
||||
|
||||
def get_all_test_seaweed():
|
||||
return list(seaweed.find())
|
||||
Reference in New Issue
Block a user