Commit 9a711f24 authored by Nicolas Joyard's avatar Nicolas Joyard
Browse files

Use PositionScore in global representative score

parent 705915a4
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('representatives_recommendations', '0008_representativescore_use_positions'),
('representatives_positions', '0006_positionscore'),
]
operations = [
migrations.RunSQL(
"""
CREATE OR REPLACE VIEW "representatives_recommendations_representativescore"
AS
SELECT
"representatives_representative"."id" AS "representative_id",
COALESCE(SUM("scoresource"."score"), 0) AS "score"
FROM
"representatives_representative"
LEFT OUTER JOIN (
SELECT
"representatives_recommendations_votescores"."representative_id" AS "representative_id",
"representatives_recommendations_votescores"."score" AS "score"
FROM "representatives_recommendations_votescores"
UNION ALL
SELECT
"representatives_positions_positionscore"."representative_id" AS "representative_id",
"representatives_positions_positionscore"."score" AS "score"
FROM "representatives_positions_positionscore"
) "scoresource" ON "scoresource"."representative_id" = "representatives_representative"."id"
GROUP BY "representatives_representative"."id"
"""
)
]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment