Ejemplo n.º 1
0
 def kafka_topic(self):
     """if set, this will use a kafka feed instead of couch for the pillow"""
     from corehq.apps.change_feed.document_types import get_doc_meta_object_from_document
     from corehq.apps.change_feed.topics import get_topic
     meta = get_doc_meta_object_from_document(
         self.document_class().to_json())
     return get_topic(meta)
Ejemplo n.º 2
0
def IntraHealthFormFluffPillow(delete_filtered=False):
    return get_multi_fluff_pillow(
        indicator_classes=[
            TauxDeSatisfactionFluff,
            CouvertureFluff,
            RecapPassageFluff,
            IntraHealthFluff,
            TauxDeRuptureFluff,
            LivraisonFluff,
        ],
        name='IntraHealthFormFluff',
        kafka_topic=get_topic(get_doc_meta_object_from_document(XFormInstance().to_json())),
        delete_filtered=delete_filtered
    )
Ejemplo n.º 3
0
 def process_change(self, pillow_instance, change, do_set_checkpoint=False):
     document_type = _get_document_type(change.document)
     if document_type:
         assert change.document is not None
         change_meta = ChangeMeta(
             document_id=change.id,
             data_source_type=self._data_source_type,
             data_source_name=self._data_source_name,
             document_type=document_type,
             document_subtype=_get_document_subtype(change.document),
             domain=change.document.get('domain', None),
             is_deletion=change.deleted,
         )
         self._producer.send_change(get_topic(document_type), change_meta)
Ejemplo n.º 4
0
def M4ChangeFormFluffPillow(delete_filtered=False):
    return get_multi_fluff_pillow(
        indicator_classes=[
            AncHmisCaseFluff,
            LdHmisCaseFluff,
            ImmunizationHmisCaseFluff,
            ProjectIndicatorsCaseFluff,
            McctMonthlyAggregateFormFluff,
            AllHmisCaseFluff,
        ],
        name='M4ChangeFormFluff',
        kafka_topic=get_topic(get_doc_meta_object_from_document(XFormInstance().to_json())),
        delete_filtered=delete_filtered
    )
Ejemplo n.º 5
0
 def process_change(self, pillow_instance, change):
     try:
         document = change.get_document()
         doc_meta = get_doc_meta_object_from_document(document)
         change_meta = change_meta_from_doc_meta_and_document(
             doc_meta=doc_meta,
             document=document,
             data_source_type=self._data_source_type,
             data_source_name=self._data_source_name,
             doc_id=change.id,
         )
     except MissingMetaInformationError:
         pass
     else:
         # change.deleted is used for hard deletions whereas change_meta.is_deletion is for soft deletions.
         # from the consumer's perspective both should be counted as deletions so just "or" them
         # note: it is strange and hard to reproduce that the couch changes feed is providing a "doc"
         # along with a hard deletion, but it is doing that in the wild so we might as well support it.
         change_meta.is_deletion = change_meta.is_deletion or change.deleted
         self._producer.send_change(get_topic(doc_meta), change_meta)
Ejemplo n.º 6
0
 def process_change(self, pillow_instance, change):
     try:
         document = change.get_document()
         doc_meta = get_doc_meta_object_from_document(document)
         change_meta = change_meta_from_doc_meta_and_document(
             doc_meta=doc_meta,
             document=document,
             data_source_type=self._data_source_type,
             data_source_name=self._data_source_name,
             doc_id=change.id,
         )
     except MissingMetaInformationError:
         pass
     else:
         # change.deleted is used for hard deletions whereas change_meta.is_deletion is for soft deletions.
         # from the consumer's perspective both should be counted as deletions so just "or" them
         # note: it is strange and hard to reproduce that the couch changes feed is providing a "doc"
         # along with a hard deletion, but it is doing that in the wild so we might as well support it.
         change_meta.is_deletion = change_meta.is_deletion or change.deleted
         self._producer.send_change(get_topic(doc_meta), change_meta)
Ejemplo n.º 7
0
 def kafka_topic(self):
     """if set, this will use a kafka feed instead of couch for the pillow"""
     from corehq.apps.change_feed.document_types import get_doc_meta_object_from_document
     from corehq.apps.change_feed.topics import get_topic
     meta = get_doc_meta_object_from_document(self.document_class().to_json())
     return get_topic(meta)