Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Anthony
memopol
Commits
9a711f24
Commit
9a711f24
authored
Sep 05, 2016
by
Nicolas Joyard
Browse files
Use PositionScore in global representative score
parent
705915a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
representatives_recommendations/migrations/0009_representativescore_use_positionscore.py
0 → 100644
View file @
9a711f24
# -*- 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"
"""
)
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment