Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ README.md
license.txt
Dockerfile
Makefile
*_matomo
*_matomo
*.sql
4 changes: 2 additions & 2 deletions matomo_pull/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def update_dates(mtm_vars):
return mtm_vars


def is_database_created(table_name='visits'):
def is_database_created(table_name='matomo.visits'):
try:
return bool(connection.execute(f"select * from {table_name}"))
except Exception:
Expand All @@ -127,7 +127,7 @@ def update_start_date_regarding_database_state(mtm_vars):
if is_database_created():
last_update = (
connection.execute(
"select date from visits order by date desc limit 1"
"select date from matomo.visits order by date desc limit 1"
).fetchall()[0][0]
).date()
return last_update + timedelta(days=1)
Expand Down
3 changes: 2 additions & 1 deletion matomo_pull/sql_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def convert_data_object_to_sql(table_name, table_params, data_object):
df.to_sql(
table_name,
s.connection,
if_exists='append'
if_exists='append',
schema='matomo'
)
print(table_name)
8 changes: 4 additions & 4 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def test_database_already_up_to_date(settings_setup, monkeypatch):
def test_database_creation(settings_setup):
conn = settings.set_database_connection(os.environ['db_name'])
conn.execute(
"create table visits(id int primary key not null, date date);"
"create table matomo.visits(id int primary key not null, date date);"
)
assert settings.is_database_created()

conn.execute("drop table visits;")
conn.execute("drop table matomo.visits;")
assert not settings.is_database_created()


Expand All @@ -69,10 +69,10 @@ def test_updating_dates(settings_setup):
conn = settings.set_database_connection(os.environ['db_name'])

conn.execute(
"create table visits(id int primary key not null, date timestamp);"
"create table matomo.visits(id int primary key not null, date timestamp);"
)
conn.execute(
f"insert into visits(id,date) values(1, '{last_update_date}')"
f"insert into matomo.visits(id,date) values(1, '{last_update_date}')"
)

vars = settings.check_mtm_vars(settings.mtm_vars)
Expand Down