-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue-218: crete migrations for default assertions
- Loading branch information
¨caiovelp¨
committed
Dec 20, 2024
1 parent
f12e42f
commit 14086d3
Showing
5 changed files
with
215 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
db/migrate/20241220124937_add_query_and_assertion_for_external_participant.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
class AddQueryAndAssertionForExternalParticipant < ActiveRecord::Migration[7.0] | ||
def up | ||
execute <<-SQL | ||
INSERT INTO queries (name, sql, description, created_at, updated_at) | ||
VALUES ( | ||
'DECLARAÇÃO - Participante externo em defesa de tese', | ||
'SELECT | ||
s.name as nome_aluno, | ||
l.name as nivel_aluno, | ||
e.thesis_defense_date as data, | ||
p.name as nome_professor | ||
FROM | ||
thesis_defense_committee_participations tdcp, enrollments e, students s, professors p, levels l | ||
WHERE | ||
tdcp.enrollment_id = e.id AND | ||
e.student_id = s.id AND | ||
tdcp.professor_id = p.id AND | ||
e.level_id = l.id AND | ||
e.enrollment_number = :matricula_aluno AND | ||
p.cpf = :cpf_professor', | ||
'Declaração de participante externo em defesa de dissertação.', | ||
CURRENT_TIMESTAMP, | ||
CURRENT_TIMESTAMP | ||
); | ||
SQL | ||
|
||
query_id = execute("SELECT last_insert_rowid()").first['last_insert_rowid()'] | ||
|
||
execute <<-SQL | ||
INSERT INTO query_params (query_id, name, default_value, value_type, created_at, updated_at) | ||
VALUES | ||
(#{query_id}, 'matricula_aluno', NULL, 'String', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), | ||
(#{query_id}, 'cpf_professor', NULL, 'String', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); | ||
SQL | ||
|
||
execute <<-SQL | ||
INSERT INTO assertions (name, query_id, assertion_template, created_at, updated_at) | ||
VALUES ( | ||
'Declaração de participante externo em defesa de tese', | ||
#{query_id}, | ||
'A quem possa interessar, Declaramos que o professor <%= var(''nome_professor'') %> participou da banca de defesa da dissertação de <%= var(''nivel_aluno'') %> de <%= var(''nome_aluno'') %>, no dia <%= var(''data'') %>.', | ||
CURRENT_TIMESTAMP, | ||
CURRENT_TIMESTAMP | ||
); | ||
SQL | ||
end | ||
|
||
def down | ||
execute <<-SQL | ||
DELETE FROM assertions | ||
WHERE name = 'Declaração de participante externo em defesa de tese'; | ||
SQL | ||
|
||
execute <<-SQL | ||
DELETE FROM query_params | ||
WHERE query_id = (SELECT id FROM queries WHERE name = 'DECLARAÇÃO - Participante externo em defesa de tese'); | ||
SQL | ||
|
||
execute <<-SQL | ||
DELETE FROM queries | ||
WHERE name = 'DECLARAÇÃO - Participante externo em defesa de tese'; | ||
SQL | ||
end | ||
end |
69 changes: 69 additions & 0 deletions
69
db/migrate/20241220144358_add_query_and_assertion_for_examining_board.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
class AddQueryAndAssertionForExaminingBoard < ActiveRecord::Migration[7.0] | ||
def up | ||
execute <<-SQL | ||
INSERT INTO queries (name, sql, description, created_at, updated_at) | ||
VALUES ( | ||
'DECLARAÇÃO - Banca examinadora de defesa', | ||
'SELECT | ||
s.name as nome_aluno, | ||
l.name as nivel_aluno, | ||
e.thesis_title as titulo_tese, | ||
e.thesis_defense_date as data, | ||
p.name as nome_professor, | ||
i.code as codigo_instituicao | ||
FROM | ||
thesis_defense_committee_participations tdcp, enrollments e, students s, professors p, levels l, institutions i | ||
WHERE | ||
tdcp.enrollment_id = e.id AND | ||
e.student_id = s.id AND | ||
tdcp.professor_id = p.id AND | ||
e.level_id = l.id AND | ||
i.id = p.institution_id AND | ||
e.enrollment_number = :matricula_aluno', | ||
'Recupera informações necessárias para a declaração de banca examinadora de defesa de um determinado aluno', | ||
CURRENT_TIMESTAMP, | ||
CURRENT_TIMESTAMP | ||
); | ||
SQL | ||
|
||
query_id = execute("SELECT last_insert_rowid()").first['last_insert_rowid()'] | ||
|
||
execute <<-SQL | ||
INSERT INTO query_params (query_id, name, default_value, value_type, created_at, updated_at) | ||
VALUES | ||
(#{query_id}, 'matricula_aluno', NULL, 'String', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); | ||
SQL | ||
|
||
execute <<-SQL | ||
INSERT INTO assertions (name, query_id, assertion_template, created_at, updated_at) | ||
VALUES ( | ||
'Declaração da ata de defesa', | ||
#{query_id}, | ||
'Declaro, para os devidos fins, que a Banca Examinadora da Defesa de Dissertação de Mestrado intitulada “<%= var(''titulo_tese'') %>”, apresentada pelo aluno <%= var(''nome_aluno'') %>, no dia <%= var(''data'') %>, no no Instituto de Computação da Universidade Federal Fluminense, foi composta pelos seguintes membros: | ||
<% records.each do |record| %> | ||
- Prof. <%= record[''nome_professor''] %>, <%= record[''codigo_instituicao''] %> | ||
<% end %>', | ||
CURRENT_TIMESTAMP, | ||
CURRENT_TIMESTAMP | ||
); | ||
SQL | ||
end | ||
|
||
def down | ||
execute <<-SQL | ||
DELETE FROM assertions | ||
WHERE name = 'Declaração da ata de defesa'; | ||
SQL | ||
|
||
execute <<-SQL | ||
DELETE FROM query_params | ||
WHERE query_id = (SELECT id FROM queries WHERE name = 'DECLARAÇÃO - Banca examinadora de defesa'); | ||
SQL | ||
|
||
execute <<-SQL | ||
DELETE FROM queries | ||
WHERE name = 'DECLARAÇÃO - Banca examinadora de defesa'; | ||
SQL | ||
end | ||
end |
80 changes: 80 additions & 0 deletions
80
db/migrate/20241220150416_add_query_and_assertion_for_avulso_student.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
class AddQueryAndAssertionForAvulsoStudent < ActiveRecord::Migration[7.0] | ||
def up | ||
execute <<-SQL | ||
INSERT INTO queries (name, sql, description, created_at, updated_at) | ||
VALUES ( | ||
'DECLARAÇÃO - Disciplinas de aluno avulso', | ||
'SELECT | ||
s.name as nome_aluno, | ||
s.cpf as cpf_aluno, | ||
c.name as nome_disciplina, | ||
c.workload as carga_horaria, | ||
cs.year as ano_disciplina, | ||
cs.semester as semestre_disciplina, | ||
ce.grade as nota, | ||
ce.situation as situacao | ||
FROM | ||
course_classes cs, class_enrollments ce, enrollments e, courses c, students s | ||
WHERE | ||
cs.id = ce.course_class_id AND | ||
ce.enrollment_id = e.id AND | ||
c.id = cs.course_id AND | ||
e.student_id = s.id AND | ||
cs.year = :ano_semestre_busca AND | ||
cs.semester = :numero_semestre_busca AND | ||
e.enrollment_number = :matricula_aluno', | ||
'Recupera as notas das disciplinas que um avulso obteve num determinado ano/semestre.', | ||
CURRENT_TIMESTAMP, | ||
CURRENT_TIMESTAMP | ||
); | ||
SQL | ||
|
||
query_id = execute("SELECT last_insert_rowid()").first['last_insert_rowid()'] | ||
|
||
execute <<-SQL | ||
INSERT INTO query_params (query_id, name, default_value, value_type, created_at, updated_at) | ||
VALUES | ||
(#{query_id}, 'matricula_aluno', NULL, 'String', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), | ||
(#{query_id}, 'ano_semestre_busca', NULL, 'Integer', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), | ||
(#{query_id}, 'numero_semestre_busca', NULL, 'Integer', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); | ||
SQL | ||
|
||
execute <<-SQL | ||
INSERT INTO assertions (name, query_id, assertion_template, created_at, updated_at) | ||
VALUES ( | ||
'Declaração de relatório de disciplinas para aluno avulso', | ||
#{query_id}, | ||
'DECLARAÇÃO | ||
Declaro, para os devidos fins, que <%= var(''nome_aluno'') %> cursou como Aluno Avulso as seguintes disciplinas do Programa de Pós-Graduação em Computação, nos termos do Art. 15 do Regulamento dos Programas de Pós-Graduação Stricto Sensu da Universidade Federal Fluminense. | ||
<% records.each do |record| %> | ||
<%= record[''counter''] %>. Nome da disciplina: "<%= record[''nome_disciplina''] %>" | ||
Carga horaria total: <%= record[''carga_horaria''] %> | ||
Período: <%= var(''ano_disciplina'') %>/<%= var(''semestre_disciplina'') %> | ||
Nota: <%= record[''nota''] %> | ||
Situação final: <%= record[''situacao''] %> | ||
<% end %>', | ||
CURRENT_TIMESTAMP, | ||
CURRENT_TIMESTAMP | ||
); | ||
SQL | ||
end | ||
|
||
def down | ||
execute <<-SQL | ||
DELETE FROM assertions | ||
WHERE name = 'Declaração de relatório de disciplinas para aluno avulso'; | ||
SQL | ||
|
||
execute <<-SQL | ||
DELETE FROM query_params | ||
WHERE query_id = (SELECT id FROM queries WHERE name = 'DECLARAÇÃO - Disciplinas de aluno avulso'); | ||
SQL | ||
|
||
execute <<-SQL | ||
DELETE FROM queries | ||
WHERE name = 'DECLARAÇÃO - Disciplinas de aluno avulso'; | ||
SQL | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.