Skip to content

Commit a2fd45f

Browse files
committed
Refactor: Remove m_users_table member variable
Making the code simpler.
1 parent b54c9ae commit a2fd45f

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/middle-pgsql.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,10 +1086,12 @@ void middle_pgsql_t::start()
10861086

10871087
void middle_pgsql_t::write_users_table()
10881088
{
1089-
log_info("Writing {} entries to table '{}'...", m_users.size(),
1090-
m_users_table.name());
1089+
auto const table_name = m_options->prefix + "_users";
1090+
1091+
log_info("Writing {} entries to table '{}'...", m_users.size(), table_name);
1092+
10911093
auto const users_table = std::make_shared<db_target_descr_t>(
1092-
m_users_table.schema(), m_users_table.name(), "id");
1094+
m_options->dbschema, table_name, "id");
10931095

10941096
for (auto const &[id, name] : m_users) {
10951097
m_db_copy.new_line(users_table);
@@ -1100,29 +1102,28 @@ void middle_pgsql_t::write_users_table()
11001102

11011103
m_users.clear();
11021104

1103-
analyze_table(m_db_connection, m_users_table.schema(),
1104-
m_users_table.name());
1105+
analyze_table(m_db_connection, m_options->dbschema, table_name);
11051106
}
11061107

11071108
void middle_pgsql_t::update_users_table()
11081109
{
1109-
log_info("Writing {} entries to table '{}'...", m_users.size(),
1110-
m_users_table.name());
1110+
auto const table_name = m_options->prefix + "_users";
1111+
1112+
log_info("Writing {} entries to table '{}'...", m_users.size(), table_name);
11111113

11121114
m_db_connection.prepare(
11131115
"insert_user",
11141116
"INSERT INTO {}.\"{}\" (id, name) VALUES ($1::int8, $2::text)"
11151117
" ON CONFLICT (id) DO UPDATE SET id=EXCLUDED.id",
1116-
m_users_table.schema(), m_users_table.name());
1118+
m_options->dbschema, table_name);
11171119

11181120
for (auto const &[id, name] : m_users) {
11191121
m_db_connection.exec_prepared("insert_user", id, name);
11201122
}
11211123

11221124
m_users.clear();
11231125

1124-
analyze_table(m_db_connection, m_users_table.schema(),
1125-
m_users_table.name());
1126+
analyze_table(m_db_connection, m_options->dbschema, table_name);
11261127
}
11271128

11281129
void middle_pgsql_t::stop()
@@ -1272,8 +1273,6 @@ middle_pgsql_t::middle_pgsql_t(std::shared_ptr<thread_pool_t> thread_pool,
12721273
m_tables.nodes() = table_desc{*options, "nodes"};
12731274
m_tables.ways() = table_desc{*options, "ways"};
12741275
m_tables.relations() = table_desc{*options, "rels"};
1275-
1276-
m_users_table = table_desc{*options, "users"};
12771276
}
12781277

12791278
void middle_pgsql_t::set_requirements(

src/middle-pgsql.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ struct middle_pgsql_t : public middle_t
178178

179179
std::map<osmium::user_id_type, std::string> m_users;
180180
osmium::nwr_array<table_desc> m_tables;
181-
table_desc m_users_table;
182181

183182
options_t const *m_options;
184183

0 commit comments

Comments
 (0)