Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove repo_status field #2253

Merged
merged 2 commits into from
Mar 20, 2023
Merged
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
28 changes: 10 additions & 18 deletions augur/api/routes/collection_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,18 @@
def commit_collection_status(): # TODO: make this name automatic - wrapper?
commit_collection_sql = s.sql.text("""
SELECT
repo_id,
repo_path,
repo_name,
repo_git,
repo_status
r.repo_id,
r.repo_path,
r.repo_name,
r.repo_git,
c.facade_status as repo_status
FROM
repo
repo r,
collection_status c
WHERE
repo_status != 'Complete'
UNION
SELECT
repo_id,
repo_path,
repo_name,
repo_git,
repo_status
FROM
repo
WHERE
repo_status = 'Complete'
r.repo_id = c.repo_id
AND
c.facade_status = 'Success';
""")
results = pd.read_sql(commit_collection_sql, engine)
data = results.to_json(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,43 +101,3 @@ def test_insert_repo(test_db_engine):
finally:
with test_db_engine.connect() as connection:
connection.execute(clear_tables_statement)


def test_add_repo_row_with_updates(test_db_engine):

clear_tables = ["user_repos", "user_groups", "repo", "repo_groups", "users"]
clear_tables_statement = get_repo_related_delete_statements(clear_tables)

try:
data = {"old_rg_id": 1, "new_rg_id": 2, "repo_id": 1, "repo_id_2": 2, "tool_source": "Test",
"repo_url": "https://github.com/chaoss/augur", "repo_url_2": "https://github.com/chaoss/grimoirelab-perceval-opnfv", "repo_status": "Complete"}

with test_db_engine.connect() as connection:

query_statements = []
query_statements.append(clear_tables_statement)
query_statements.append(get_repo_group_insert_statement(data["old_rg_id"]))
query_statements.append(get_repo_group_insert_statement(data["new_rg_id"]))
query_statements.append(get_repo_insert_statement(data["repo_id"], data["old_rg_id"], repo_url=data["repo_url"], repo_status=data["repo_status"]))
query = s.text("".join(query_statements))

connection.execute(query)

with DatabaseSession(logger, test_db_engine) as session:

result = Repo.insert(session, data["repo_url"], data["new_rg_id"], data["tool_source"]) is not None
assert result == data["repo_id"]

with test_db_engine.connect() as connection:

result = get_repos(connection, where_string=f"WHERE repo_git='{data['repo_url']}'")
assert result is not None
assert len(result) == 1

value = dict(result[0])
assert value["repo_status"] == data["repo_status"]
assert value["repo_group_id"] == data["new_rg_id"]

finally:
with test_db_engine.connect() as connection:
connection.execute(clear_tables_statement)
2 changes: 1 addition & 1 deletion tests/test_applicaton/test_db/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def test_insert_issue_data_with_invalid_strings(test_db_engine):
DELETE FROM "augur_data"."repo_groups";
INSERT INTO "augur_data"."repo_groups" ("repo_group_id", "rg_name", "rg_description", "rg_website", "rg_recache", "rg_last_modified", "rg_type", "tool_source", "tool_version", "data_source", "data_collection_date") VALUES (1, 'Default Repo Group', 'The default repo group created by the schema generation script', '', 0, '2019-06-03 15:55:20', 'GitHub Organization', 'load', 'one', 'git', '2019-06-05 13:36:25');

INSERT INTO "augur_data"."repo" ("repo_id", "repo_group_id", "repo_git", "repo_path", "repo_name", "repo_added", "repo_status", "repo_type", "url", "owner_id", "description", "primary_language", "created_at", "forked_from", "updated_at", "repo_archived_date_collected", "repo_archived", "tool_source", "tool_version", "data_source", "data_collection_date") VALUES (1, 1, 'https://github.com/chaoss/augur', NULL, NULL, '2022-08-15 21:08:07', 'New', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'CLI', '1.0', 'Git', '2022-08-15 21:08:07');
INSERT INTO "augur_data"."repo" ("repo_id", "repo_group_id", "repo_git", "repo_path", "repo_name", "repo_added", "repo_type", "url", "owner_id", "description", "primary_language", "created_at", "forked_from", "updated_at", "repo_archived_date_collected", "repo_archived", "tool_source", "tool_version", "data_source", "data_collection_date") VALUES (1, 1, 'https://github.com/chaoss/augur', NULL, NULL, '2022-08-15 21:08:07', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'CLI', '1.0', 'Git', '2022-08-15 21:08:07');
""")

connection.execute(query)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tasks/test_github_tasks/test_pull_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def test_insert_prs(github_api_key_headers, test_db_session, repo):
DELETE FROM "augur_data"."repo_groups";
INSERT INTO "augur_data"."repo_groups" ("repo_group_id", "rg_name", "rg_description", "rg_website", "rg_recache", "rg_last_modified", "rg_type", "tool_source", "tool_version", "data_source", "data_collection_date") VALUES (1, 'Default Repo Group', 'The default repo group created by the schema generation script', '', 0, '2019-06-03 15:55:20', 'GitHub Organization', 'load', 'one', 'git', '2019-06-05 13:36:25');

INSERT INTO "augur_data"."repo" ("repo_id", "repo_group_id", "repo_git", "repo_path", "repo_name", "repo_added", "repo_status", "repo_type", "url", "owner_id", "description", "primary_language", "created_at", "forked_from", "updated_at", "repo_archived_date_collected", "repo_archived", "tool_source", "tool_version", "data_source", "data_collection_date") VALUES (1, 1, 'https://github.com/chaoss/augur', NULL, NULL, '2022-08-15 21:08:07', 'New', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'CLI', '1.0', 'Git', '2022-08-15 21:08:07');
INSERT INTO "augur_data"."repo" ("repo_id", "repo_group_id", "repo_git", "repo_path", "repo_name", "repo_added", "repo_type", "url", "owner_id", "description", "primary_language", "created_at", "forked_from", "updated_at", "repo_archived_date_collected", "repo_archived", "tool_source", "tool_version", "data_source", "data_collection_date") VALUES (1, 1, 'https://github.com/chaoss/augur', NULL, NULL, '2022-08-15 21:08:07', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'CLI', '1.0', 'Git', '2022-08-15 21:08:07');
""")

connection.execute(query, **contributor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def set_up_repo_groups(database_connection):
repo_group_IDs = [group[0] for group in df.fetchall()]

insertSQL = s.sql.text("""
INSERT INTO augur_data.repo(repo_group_id, repo_git, repo_status,
INSERT INTO augur_data.repo(repo_group_id, repo_git,
tool_source, tool_version, data_source, data_collection_date)
VALUES (:repo_group_id, :repo_git, 'New', 'CLI', 1.0, 'Git', CURRENT_TIMESTAMP)
VALUES (:repo_group_id, :repo_git, 'CLI', 1.0, 'Git', CURRENT_TIMESTAMP)
""")

with open("tests/test_workers/test_facade/test_facade_contributor_interface/test_repos.csv") as upload_repos_file:
Expand Down