akvo.rsr.models.result.indicator_period_aggregation module

class akvo.rsr.models.result.indicator_period_aggregation.PeriodActualValue(id, period, measure, value, numerator, denominator)[source]

Bases: View

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

denominator

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

measure

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

numerator

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
period

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

period_id
sql = '\n    SELECT\n        -- row_number() OVER... creates an artificial "pk" column, without which Django will protest\n        row_number() OVER (ORDER BY period.id) AS id,\n        period.id AS period_id,\n        indicator.measure as measure,\n        sum((update.value) :: DECIMAL(20,2)) AS value,\n        sum((update.numerator) :: DECIMAL(20,2)) AS numerator,\n        sum((update.denominator) :: DECIMAL(20,2)) AS denominator\n    FROM\n        rsr_indicatorperiod period,\n        rsr_indicator indicator,\n        rsr_indicatorperioddata update\n    WHERE\n        (\n            (((indicator.id = period.indicator_id) AND\n            (period.id = update.period_id)) AND\n            ((update.status) :: TEXT = \'A\' :: TEXT)) AND\n            ((update.value) :: TEXT ~ \'^\\d+\\.?\\d{0,2}$\' :: TEXT OR update.value IS NULL)\n        )\n    GROUP BY period.id, indicator.measure;\n'
value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class akvo.rsr.models.result.indicator_period_aggregation.PeriodDisaggregation(id, indicator, period, dimension_name, dimension_value, value, numerator, denominator)[source]

Bases: View

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

denominator

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

dimension_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

dimension_value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

indicator

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

indicator_id
numerator

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
period

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

period_id
sql = '\n    WITH aggregated_disaggs AS (\n        SELECT\n            update.period_id,\n            disagg.dimension_value_id,\n            sum((disagg.value) :: DECIMAL(20,2)) AS value,\n            sum((disagg.numerator) :: DECIMAL(20,2)) AS numerator,\n            sum((disagg.denominator) :: DECIMAL(20,2)) AS denominator\n        FROM\n            rsr_disaggregation disagg,\n            rsr_indicatorperioddata "update"\n        WHERE\n            update.status = \'A\' AND\n            disagg.update_id = update.id\n        GROUP BY\n            disagg.dimension_value_id, update.period_id\n    ),\n    period_disaggs AS (\n        SELECT DISTINCT\n            indicator.id AS indicator_id,\n            period.id AS period_id,\n            dimensionname.name AS dimension_name,\n            dimensionvalue.value AS dimension_value,\n            agg.value,\n            agg.numerator,\n            agg.denominator\n        FROM\n            rsr_indicator indicator,\n            rsr_indicatorperiod period,\n            rsr_indicator_dimension_names indicator_dimensions,\n            aggregated_disaggs agg,\n            rsr_indicatordimensionname dimensionname,\n            rsr_indicatordimensionvalue dimensionvalue\n        WHERE\n            indicator.id = period.indicator_id AND\n            period.id = agg.period_id AND\n            dimensionvalue.id = agg.dimension_value_id AND\n            dimensionname.id = dimensionvalue.name_id AND\n            indicator_dimensions.indicatordimensionname_id = dimensionname.id AND\n            indicator_dimensions.indicator_id = indicator.id\n    )\n    SELECT\n        row_number() OVER (ORDER BY indicator_id) AS id,\n        *\n    FROM period_disaggs\n'
value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.