Aneta
9 years ago
12 changed files with 284 additions and 41 deletions
@ -0,0 +1,75 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import models, migrations |
||||
|
import django_countries.fields |
||||
|
import seminar.models |
||||
|
import django.utils.timezone |
||||
|
from django.conf import settings |
||||
|
|
||||
|
CREATE_VIEWS=""" |
||||
|
drop view seminar_body_k_cislu; |
||||
|
drop view seminar_body_za_cislo; |
||||
|
|
||||
|
create view seminar_body_za_cislo as |
||||
|
select |
||||
|
seminar_reseni.cislo_body_id || '-' || seminar_reseni.resitel_id as id, |
||||
|
seminar_reseni.cislo_body_id as cislo_id, |
||||
|
seminar_reseni.resitel_id as resitel_id, |
||||
|
seminar_cisla.cislo as cislo, |
||||
|
seminar_cisla.rocnik_id as rocnik_id, |
||||
|
seminar_rocniky.rocnik as rocnik, |
||||
|
seminar_cisla.verejna_vysledkovka as verejna_vysledkovka, |
||||
|
sum(seminar_reseni.body) as body |
||||
|
from |
||||
|
seminar_reseni |
||||
|
inner join seminar_cisla on seminar_reseni.cislo_body_id = seminar_cisla.id |
||||
|
inner join seminar_rocniky on seminar_cisla.rocnik_id = seminar_rocniky.id |
||||
|
group by seminar_reseni.cislo_body_id, seminar_reseni.resitel_id, seminar_cisla.cislo, |
||||
|
seminar_cisla.rocnik_id, seminar_rocniky.rocnik, seminar_cisla.verejna_vysledkovka |
||||
|
order by body desc; |
||||
|
|
||||
|
create view seminar_body_k_cislu_rocnik as |
||||
|
select |
||||
|
akt_body.id as id, |
||||
|
akt_body.cislo_id as cislo_id, |
||||
|
akt_body.resitel_id as resitel_id, |
||||
|
akt_body.body as body, |
||||
|
sum(min_body.body) as body_celkem |
||||
|
from |
||||
|
seminar_body_za_cislo as akt_body |
||||
|
inner join seminar_body_za_cislo as min_body on |
||||
|
(akt_body.resitel_id = min_body.resitel_id and |
||||
|
(akt_body.rocnik = min_body.rocnik and akt_body.cislo >= min_body.cislo) |
||||
|
) |
||||
|
group by akt_body.id, akt_body.cislo_id, akt_body.resitel_id, akt_body.body |
||||
|
order by body_celkem desc; |
||||
|
|
||||
|
create view seminar_body_k_cislu_odjakziva as |
||||
|
select |
||||
|
akt_body.id as id, |
||||
|
akt_body.cislo_id as cislo_id, |
||||
|
akt_body.resitel_id as resitel_id, |
||||
|
akt_body.body as body, |
||||
|
sum(min_body.body) as body_celkem |
||||
|
from |
||||
|
seminar_body_za_cislo as akt_body |
||||
|
inner join seminar_body_za_cislo as min_body on |
||||
|
(akt_body.resitel_id = min_body.resitel_id and |
||||
|
((akt_body.rocnik = min_body.rocnik and akt_body.cislo >= min_body.cislo) or |
||||
|
(akt_body.rocnik < min_body.rocnik) |
||||
|
) |
||||
|
) |
||||
|
group by akt_body.id, akt_body.cislo_id, akt_body.resitel_id, akt_body.body |
||||
|
order by body_celkem desc; |
||||
|
|
||||
|
""" |
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [("seminar", "0027_export_flag_a_typ_akce")] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunSQL(sql=CREATE_VIEWS) |
||||
|
] |
||||
|
|
@ -0,0 +1,51 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import models, migrations |
||||
|
import django_countries.fields |
||||
|
import seminar.models |
||||
|
import django.utils.timezone |
||||
|
from django.conf import settings |
||||
|
|
||||
|
CREATE_VIEWS=""" |
||||
|
|
||||
|
drop view seminar_body_k_cislu_rocnik; |
||||
|
create view seminar_body_k_cislu_rocnik as |
||||
|
select |
||||
|
seminar_cisla.id || '-' || min_body.resitel_id as id, |
||||
|
seminar_cisla.id as cislo_id, |
||||
|
min_body.resitel_id as resitel_id, |
||||
|
sum(min_body.body) as body |
||||
|
from |
||||
|
seminar_cisla |
||||
|
inner join seminar_body_za_cislo as min_body on |
||||
|
(min_body.rocnik_id = seminar_cisla.rocnik_id and seminar_cisla.cislo >= min_body.cislo) |
||||
|
group by seminar_cisla.id, min_body.resitel_id |
||||
|
order by body desc; |
||||
|
|
||||
|
drop view seminar_body_k_cislu_odjakziva; |
||||
|
create view seminar_body_k_cislu_odjakziva as |
||||
|
select |
||||
|
seminar_cisla.id || '-' || min_body.resitel_id as id, |
||||
|
seminar_cisla.id as cislo_id, |
||||
|
min_body.resitel_id as resitel_id, |
||||
|
sum(min_body.body) as body |
||||
|
from |
||||
|
seminar_cisla |
||||
|
inner join seminar_rocniky on |
||||
|
(seminar_cisla.rocnik_id = seminar_rocniky.id) |
||||
|
inner join seminar_body_za_cislo as min_body on |
||||
|
(min_body.rocnik_id = seminar_cisla.rocnik_id and seminar_cisla.cislo >= min_body.cislo) or |
||||
|
(min_body.rocnik < seminar_rocniky.rocnik) |
||||
|
group by seminar_cisla.id, min_body.resitel_id |
||||
|
order by body desc; |
||||
|
""" |
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [("seminar", "0028_add_body_celkem_views")] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunSQL(sql=CREATE_VIEWS) |
||||
|
] |
||||
|
|
@ -0,0 +1,24 @@ |
|||||
|
{% extends "base.html" %} |
||||
|
|
||||
|
{% block content %} |
||||
|
<div> |
||||
|
<h2>Stav databáze</h2> |
||||
|
|
||||
|
<h3>Řešitelé</h3> |
||||
|
|
||||
|
<div>Řešitelů: {{ resitele |length}} ({{ muzi |length}} mužů, {{ zeny |length}} žen)</div> |
||||
|
<div>Křestní jména mužů:</div> |
||||
|
<p><code>{% for n, c in jmena_muzu.items %}{{ n }} ({{ c }}), {% endfor %}</code> |
||||
|
<div>Křestní jména žen:</div> |
||||
|
<p><code>{% for n, c in jmena_zen.items %}{{ n }} ({{ c }}), {% endfor %}</code> |
||||
|
|
||||
|
<h3>Nastavení</h3> |
||||
|
|
||||
|
<h3>Problémy</h3> |
||||
|
{% for p in problemy %} |
||||
|
<div>{{ p |safe }}</div> |
||||
|
{% endfor %} |
||||
|
|
||||
|
</div> |
||||
|
{% endblock content %} |
||||
|
|
Loading…
Reference in new issue