diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2015-10-12 13:04:19 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2015-10-12 13:04:19 +0200 |
commit | c4b71579939c9461379472ee36675ff6ecb1b417 (patch) | |
tree | bcc8eac2dd47919430023b4e4a3747683452cfd7 /scripts | |
parent | fe0002e7fd5a3631d6a7cd8b0a3cdbd2b55d7aa1 (diff) |
Drop name column from language/group/problem tables
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/build_web_resources.py | 5 | ||||
-rw-r--r-- | scripts/sqlite_to_pg.py | 10 |
2 files changed, 7 insertions, 8 deletions
diff --git a/scripts/build_web_resources.py b/scripts/build_web_resources.py index e581fd0..d109eb0 100644 --- a/scripts/build_web_resources.py +++ b/scripts/build_web_resources.py @@ -186,7 +186,7 @@ try: lang_data['translations'] = load_translation_data(lang_identifier, language_props) copy_web_resources(lang_identifier, [lang_identifier]) db_add('language', lang_identifier, - {'id': lang_data['id'], 'name': lang_identifier, 'identifier': lang_identifier}) + {'id': lang_data['id'], 'identifier': lang_identifier}) groups_path = os.path.join(lang_path, 'problems') for group_identifier in os.listdir(groups_path): @@ -205,7 +205,7 @@ try: group_data['problems'] = [] group_data['translations'] = load_translation_data(group_package, group_props) db_add('problem_group', group_identifier, - {'id': group_data['id'], 'name': group_identifier, 'identifier': group_identifier}) + {'id': group_data['id'], 'identifier': group_identifier}) for problem_identifier in os.listdir(group_path): problem_path = os.path.join(group_path, problem_identifier) @@ -250,7 +250,6 @@ try: 'id': problem_data['id'], 'language_id': lang_data['id'], 'problem_group_id': group_data['id'], - 'name': problem_identifier, 'identifier': problem_identifier }) diff --git a/scripts/sqlite_to_pg.py b/scripts/sqlite_to_pg.py index 29e1317..b148be6 100644 --- a/scripts/sqlite_to_pg.py +++ b/scripts/sqlite_to_pg.py @@ -130,10 +130,10 @@ def convert_attempt(row): return (row[0], row[1] != 0, row[2], row[3], row[4], '[' + ','.join(new_trace) + ']'), None def convert_problem_group(row): - return (row[0], row[1], filenamefy(row[1])), None + return (row[0], filenamefy(row[1])), None def convert_problem(row): - return (row[0], row[1], row[2], row[3] != 0, filenamefy(row[2])), None + return (row[0], row[1], filenamefy(row[2])), None if __name__ == '__main__': sqc = sqlite3.connect('db.sqlite3') @@ -144,7 +144,7 @@ if __name__ == '__main__': log('Creating language prolog') cur = pgc.cursor() try: - cur.execute("insert into language (name, identifier) values ('Prolog', 'prolog') returning id") + cur.execute("insert into language (identifier) values ('prolog') returning id") _language_prolog_id = cur.fetchone()[0] finally: cur.close() @@ -170,13 +170,13 @@ if __name__ == '__main__': log('Copying tutor_group -> problem_group') copy_table( 'select id, name from tutor_group', - 'insert into problem_group (id, name, identifier) values (%s, %s, %s)', + 'insert into problem_group (id, identifier) values (%s, %s)', convert_problem_group, None, 'problem_group_id_seq') log('Copying tutor_problem -> problem') copy_table( 'select id, group_id, name, visible from tutor_problem', - 'insert into problem (id, language_id, problem_group_id, name, identifier) values (%s, ' + str(_language_prolog_id) + ', %s, %s, %s)', + 'insert into problem (id, language_id, problem_group_id, identifier) values (%s, ' + str(_language_prolog_id) + ', %s, %s)', convert_problem, None, 'problem_id_seq') log('Copying tutor_attempt -> solution') |