コード例 #1
0
    def create_fact(cls, **data):
        client = DimensionClient.insert(client_id=data['client_id'])
        item = DimensionItem.insert(item_id=data['item_id'])
        data_role = DimensionDataRole.insert(role=data['data_role'])

        definition = DimensionDefinition.insert(definition=data['definition'])

        processing_state = DimensionProcessingState.insert(processing_state=data['processing_state'])
        territory = DimensionTerritory.insert(code=data['territory'])

        asset = DimensionAssets.insert(
            asset_id=data['asset_id'],
            type=data['asset_type']
        )

        provider = DimensionItemProvider.insert(
            True,
            provider_id=data['provider_item_id'],
            provider_name=data['provider'],
            )


        delivery_date = datetime.datetime.strptime(str(data['delivery_date']), settings.DATETIME_FORMAT)
        event_date = datetime.datetime.strptime(data['event_time'], settings.DATETIME_FORMAT)
        event_utc_datetime = datetime.datetime.strptime(data['event_time'], settings.DATETIME_FORMAT)

        fact = FactServicesBackstageAssetMatch.objects.create(
            client=client,
            item=item,
            asset=asset,
            data_role=data_role,
            processing_state=processing_state,
            provider=provider,
            territory=territory,
            spec_name=data['spec_name'],
            delivery_date=delivery_date,
            definition=definition,
            file_size=data['file_size'],
            duration=data['duration'],
            event_date=event_date.date(),
            event_utc_date=DimensionUTCDate.date_from_datetime(datetime=data['event_time']),
            event_utc_datetime=event_utc_datetime
        )

        fact.save()
        if data['used_asset_ids']:
            for asset_id in data['used_asset_ids']:
                asset_dim = DimensionAssets.objects.get_or_create(asset_id=asset_id)
                fact.used_asset_ids.add(asset_dim[0].id)
        else:
            fact.used_asset_ids = ''

        if data['languages']:
            for language in data['languages']:
                lang_dim = DimensionLanguage.objects.get_or_create(iso_code=language)
                fact.languages.add(lang_dim[0].id)
        else:
            fact.languages = ''
        return fact
コード例 #2
0
    def create_fact(cls, **data):
        asset = DimensionAssets.insert(asset_id=data['asset_id'],
                                       type=data['asset_type'])

        unique_studio_item = DimensionStudioItem.insert(
            unique_studio_item_id=data['unique_studio_item_id'])
        studio = DimensionStudio.insert(name=data['studio'])
        data_role = DimensionDataRole.insert(role=data['data_role'])
        definition = DimensionDefinition.insert(definition=data['definition'])
        language = DimensionLanguage.insert(iso_code=data['language'])
        audio_channel = DimensionAudioChannels.insert(
            channel=data['audio_channel'])
        client = DimensionClient.insert(client_id=data['client_id'])
        vendor = DimensionVendor.insert(name=data['vendor'])

        fact = FactServicesAggregatorAggregation.objects.create(
            asset=asset,
            unique_studio_item=unique_studio_item,
            studio=studio,
            file_name=data['file_name'],
            start_time=data['start_time'],
            end_time=data['end_time'],
            file_size=data['file_size'],
            checksum=data['checksum'],
            data_role=data_role,
            content_duration=data['content_duration'],
            definition=definition,
            language=language,
            audio_channel=audio_channel,
            client=client,
            vendor=vendor,
            event_utc_date=DimensionUTCDate.date_from_datetime(
                datetime=data['event_time']),
            event_utc_datetime=data['event_time'])

        return fact
コード例 #3
0
    def create_fact(cls, **data):
        asset = DimensionAssets.insert(
            asset_id=data['asset_id'],
            type=data['asset_type']
        )

        unique_studio_item = DimensionStudioItem.insert(unique_studio_item_id=data['unique_studio_item_id'])
        studio = DimensionStudio.insert(name=data['studio'])
        data_role = DimensionDataRole.insert(role=data['data_role'])
        definition = DimensionDefinition.insert(definition=data['definition'])
        language = DimensionLanguage.insert(iso_code=data['language'])
        audio_channel = DimensionAudioChannels.insert(channel=data['audio_channel'])
        client = DimensionClient.insert(client_id=data['client_id'])
        vendor = DimensionVendor.insert(name=data['vendor'])

        fact = FactServicesAggregatorAggregation.objects.create(
            asset=asset,
            unique_studio_item=unique_studio_item,
            studio=studio,
            file_name=data['file_name'],
            start_time=data['start_time'],
            end_time=data['end_time'],
            file_size=data['file_size'],
            checksum=data['checksum'],
            data_role=data_role,
            content_duration=data['content_duration'],
            definition=definition,
            language=language,
            audio_channel=audio_channel,
            client=client,
            vendor=vendor,
            event_utc_date=DimensionUTCDate.date_from_datetime(datetime=data['event_time']),
            event_utc_datetime=data['event_time']
        )

        return fact