当前位置: 首页>>代码示例>>Python>>正文


Python App.language_stats_db_handler方法代码示例

本文整理汇总了Python中libraries.app.app.App.language_stats_db_handler方法的典型用法代码示例。如果您正苦于以下问题:Python App.language_stats_db_handler方法的具体用法?Python App.language_stats_db_handler怎么用?Python App.language_stats_db_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libraries.app.app.App的用法示例。


在下文中一共展示了App.language_stats_db_handler方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_table

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import language_stats_db_handler [as 别名]
    def init_table(self, view_count):
        try:
            App.language_stats_db_handler().table.delete()
        except:
            pass

        App.language_stats_db_handler().resource.create_table(
            TableName=App.language_stats_table_name,
            KeySchema=[
                {
                    'AttributeName': 'lang_code',
                    'KeyType': 'HASH'
                }
            ],
            AttributeDefinitions=[
                {
                    'AttributeName': 'lang_code',
                    'AttributeType': 'S'
                }
            ],
            ProvisionedThroughput={
                'ReadCapacityUnits': 5,
                'WriteCapacityUnits': 5
            },
        )

        lang_stats_data = {
            'lang_code': ViewCountTest.LANG_CODE.lower(),
            'last_updated': datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"),
            'manifest': '{}',
            'views': view_count
        }

        lang_stats = LanguageStats(lang_stats_data).insert()
        App.logger.debug("new language: " + lang_stats.lang_code)
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:37,代码来源:test_language_view_count.py

示例2: init_table

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import language_stats_db_handler [as 别名]
    def init_table(self):
        try:
            handler = App.language_stats_db_handler()
            handler.table.delete()
        except Exception as e:
            pass
        App.language_stats_db_handler().resource.create_table(
            TableName=App.language_stats_table_name,
            KeySchema=[
                {
                    'AttributeName': 'lang_code',
                    'KeyType': 'HASH'
                },
            ],
            AttributeDefinitions=[
                {
                    'AttributeName': 'lang_code',
                    'AttributeType': 'S'
                },
            ],
            ProvisionedThroughput={
                'ReadCapacityUnits': 5,
                'WriteCapacityUnits': 5
            },
            GlobalSecondaryIndexes=[
                {
                    'IndexName': 'search_type-views-index',
                    'KeySchema': [
                        {
                            'AttributeName': 'search_type',
                            'KeyType': 'HASH'
                        },
                    ],
                    'Projection': {
                        'ProjectionType': 'ALL'
                    },
                    'ProvisionedThroughput': {
                        'ReadCapacityUnits': 123,
                        'WriteCapacityUnits': 123
                    }
                },
            ],
        )

        lang_stats_data = {
            'lang_code': '?lc=en',
            'last_updated': datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"),
            'search_type': 'Y',
            'views': SearchCountTest.INITIAL_VIEW_COUNT
        }
        lang_stats = LanguageStats(lang_stats_data).insert()
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:53,代码来源:test_search_count.py

示例3: setUp

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import language_stats_db_handler [as 别名]
    def setUp(self):
        """Runs before each test."""
        App(prefix='{0}-'.format(self._testMethodName), db_connection_string='sqlite:///:memory:')
        self.tx_manager = TxManager()
        self.searches = None
        self.language_views = None

        try:
            App.language_stats_db_handler().table.delete()
        except:
            pass

        App.language_stats_db_handler().resource.create_table(
            TableName=App.language_stats_table_name,
            KeySchema=[
                {
                    'AttributeName': 'lang_code',
                    'KeyType': 'HASH'
                },
            ],
            AttributeDefinitions=[
                {
                    'AttributeName': 'lang_code',
                    'AttributeType': 'S'
                },
            ],
            ProvisionedThroughput={
                'ReadCapacityUnits': 5,
                'WriteCapacityUnits': 5
            },
            GlobalSecondaryIndexes=[
                {
                    'IndexName': 'search_type-views-index',
                    'KeySchema': [
                        {
                            'AttributeName': 'search_type',
                            'KeyType': 'HASH'
                        },
                    ],
                    'Projection': {
                        'ProjectionType': 'ALL'
                    },
                    'ProvisionedThroughput': {
                        'ReadCapacityUnits': 123,
                        'WriteCapacityUnits': 123
                    }
                },
            ],
        )
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:51,代码来源:test_language_dashboard.py

示例4: __init__

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import language_stats_db_handler [as 别名]
 def __init__(self, *args, **kwargs):
     # Init attributes
     self.lang_code = None
     self.views = 0
     self.last_updated = None
     self.monitor = True
     self.search_type = 'N'
     if 'db_handler' not in kwargs or not kwargs['db_handler']:
         kwargs['db_handler'] = App.language_stats_db_handler()
     super(LanguageStats, self).__init__(*args, **kwargs)
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:12,代码来源:language_stats.py

示例5: list_language_table_entries

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import language_stats_db_handler [as 别名]
 def list_language_table_entries(self, reverse_sort=True, max_count=20, search_type=False):
     """
     get list of all the language table records filtered by type
     :return:
     """
     search_key = 'N' if search_type is False else 'Y'
     params = {
         'IndexName': 'search_type-views-index',
         'KeyConditionExpression': Key('search_type').eq(search_key),
         'ScanIndexForward': not reverse_sort
     }
     if max_count > 0:
         params['Limit'] = max_count
     db_handler = App.language_stats_db_handler()
     results = db_handler.query_raw(**params)
     items = results['Items']
     return items
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:19,代码来源:page_metrics.py

示例6: test_dynamodb_handler

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import language_stats_db_handler [as 别名]
 def test_dynamodb_handler(self):
     self.assertIsNotNone(App.language_stats_db_handler())
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:4,代码来源:test_app.py


注:本文中的libraries.app.app.App.language_stats_db_handler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。