本文整理汇总了Python中corehq.apps.reminders.models.SurveyKeyword.get_db方法的典型用法代码示例。如果您正苦于以下问题:Python SurveyKeyword.get_db方法的具体用法?Python SurveyKeyword.get_db怎么用?Python SurveyKeyword.get_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.reminders.models.SurveyKeyword
的用法示例。
在下文中一共展示了SurveyKeyword.get_db方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSQLSyncToCouch
# 需要导入模块: from corehq.apps.reminders.models import SurveyKeyword [as 别名]
# 或者: from corehq.apps.reminders.models.SurveyKeyword import get_db [as 别名]
def testSQLSyncToCouch(self):
self.assertEqual(self.getCouchCount(), 0)
self.assertEqual(self.getSQLCount(), 0)
# Test Create
sql_obj = Keyword()
self.setRandomSQLObjectValues(sql_obj)
self.assertEqual(self.getCouchCount(), 1)
self.assertEqual(self.getSQLCount(), 1)
couch_obj = SurveyKeyword.get(sql_obj.couch_id)
self.compareObjects(couch_obj, sql_obj)
self.assertTrue(SurveyKeyword.get_db().get_rev(couch_obj._id).startswith('2-'))
# Test Update
self.setRandomSQLObjectValues(sql_obj)
self.assertEqual(self.getCouchCount(), 1)
self.assertEqual(self.getSQLCount(), 1)
couch_obj = SurveyKeyword.get(sql_obj.couch_id)
self.compareObjects(couch_obj, sql_obj)
self.assertTrue(SurveyKeyword.get_db().get_rev(couch_obj._id).startswith('3-'))
# Test Delete
couch_id = couch_obj._id
sql_obj.delete()
with self.assertRaises(ResourceNotFound):
SurveyKeyword.get(couch_id)
self.assertEqual(self.getCouchCount(), 0)
self.assertEqual(self.getSQLCount(), 0)
示例2: total
# 需要导入模块: from corehq.apps.reminders.models import SurveyKeyword [as 别名]
# 或者: from corehq.apps.reminders.models.SurveyKeyword import get_db [as 别名]
def total(self):
data = (
SurveyKeyword.get_db()
.view("reminders/survey_keywords", reduce=True, startkey=[self.domain], endkey=[self.domain, {}])
.first()
)
return data["value"] if data else 0
示例3: total
# 需要导入模块: from corehq.apps.reminders.models import SurveyKeyword [as 别名]
# 或者: from corehq.apps.reminders.models.SurveyKeyword import get_db [as 别名]
def total(self):
data = SurveyKeyword.get_db().view(
'reminders/survey_keywords',
reduce=True,
startkey=[self.domain],
endkey=[self.domain, {}],
).first()
return data['value'] if data else 0
示例4: migrate
# 需要导入模块: from corehq.apps.reminders.models import SurveyKeyword [as 别名]
# 或者: from corehq.apps.reminders.models.SurveyKeyword import get_db [as 别名]
def migrate(self, log_file):
count = 0
ids = self.get_couch_ids()
total_count = len(ids)
for doc in iter_docs_with_retry(SurveyKeyword.get_db(), ids):
try:
couch_obj = SurveyKeyword.wrap(doc)
couch_obj._migration_do_sync()
except Exception as e:
log_file.write('Could not sync SurveyKeyword %s: %s\n' % (doc['_id'], e))
count += 1
if (count % 1000) == 0:
print 'Processed %s / %s documents' % (count, total_count)