Skip to content

Commit 5478d44

Browse files
authored
Merge pull request #436 from chaoss/chore/cleanup_dead
Chore: remove dead, commented, and otherwise unused code.
2 parents 8bd2f1f + 06fb69e commit 5478d44

9 files changed

Lines changed: 1 addition & 447 deletions

File tree

collectoss/api/routes/auggie.py

Lines changed: 0 additions & 225 deletions
Original file line numberDiff line numberDiff line change
@@ -22,231 +22,6 @@
2222
API_VERSION = 'api/unstable'
2323

2424

25-
# def annotate(metadata=None, **kwargs):
26-
# """
27-
# Decorates a function as being a metric
28-
# """
29-
# if metadata is None:
30-
# metadata = {}
31-
# def decorate(func):
32-
# if not hasattr(func, 'metadata'):
33-
# func.metadata = {}
34-
# metric_metadata.append(func.metadata)
35-
36-
# func.metadata.update(metadata)
37-
# if kwargs.get('endpoint_type', None):
38-
# endpoint_type = kwargs.pop('endpoint_type')
39-
# if endpoint_type == 'repo':
40-
# func.metadata['repo_endpoint'] = kwargs.get('endpoint')
41-
# else:
42-
# func.metadata['group_endpoint'] = kwargs.get('endpoint')
43-
44-
# func.metadata.update(dict(kwargs))
45-
46-
# func.metadata['metric_name'] = request.sub('_', ' ', func.__name__).title()
47-
# func.metadata['source'] = request.sub(r'(.*\.)', '', func.__module__)
48-
# func.metadata['ID'] = "{}-{}".format(func.metadata['source'].lower(), func.metadata['tag'])
49-
50-
# return func
51-
# return decorate
52-
53-
# def add_metrics(metrics, module_name):
54-
# # find all unbound endpoint functions objects (ones that have metadata) defined the given module_name
55-
# # and bind them to the metrics class
56-
# # Derek are you proud of me
57-
# for name, obj in inspect.getmembers(sys.modules[module_name]):
58-
# if inspect.isfunction(obj) is True:
59-
# if hasattr(obj, 'metadata') is True:
60-
# setattr(metrics, name, types.MethodType(obj, metrics))
61-
62-
63-
# #@annotate(tag='slack_login')
64-
# def slack_login(metric, body):
65-
# print("slack_login")
66-
67-
# r = requests.get(
68-
# url=f'https://slack.com/api/oauth.v2.access?code={body["code"]}&client_id={os.environ["AUGGIE_CLIENT_ID"]}&client_secret={os.environ["AUGGIE_CLIENT_SECRET"]}&redirect_uri=http%3A%2F%2Flocalhost%3A8080')
69-
# data = r.json()
70-
71-
# if (data["ok"]):
72-
# print(data)
73-
# token = data["authed_user"]["access_token"]
74-
# team_id = data["team"]["id"]
75-
# webclient = slack.WebClient(token=token)
76-
77-
# user_response = webclient.users_identity()
78-
# print(user_response)
79-
# email = user_response["user"]["email"]
80-
81-
# profile_name = 'collectoss'
82-
# if os.environ.get('AUGUR_IS_PROD'):
83-
# profile_name = 'default'
84-
# print("Making Boto3 Session")
85-
# client = boto3.Session(region_name='us-east-1',
86-
# profile_name=profile_name).client('dynamodb')
87-
# response = client.get_item(
88-
# TableName="auggie-users",
89-
# Key={
90-
# "email": {"S": '{}:{}'.format(email, team_id)}
91-
# }
92-
# )
93-
94-
# if ('Item' in response):
95-
# user = response['Item']
96-
# print(user)
97-
98-
# filteredUser = {
99-
# "interestedRepos": user["interestedRepos"],
100-
# "interestedGroups": user["interestedGroups"],
101-
# "host": user["host"],
102-
# "maxMessages": user["maxMessages"],
103-
# "interestedInsights": user["interestedInsightTypes"]
104-
# }
105-
106-
# user_body = json.dumps({
107-
# 'team_id': team_id,
108-
# 'email': email,
109-
# 'user': filteredUser
110-
# })
111-
112-
# print(user_body)
113-
114-
# return user_body
115-
# else:
116-
# client.put_item(
117-
# TableName="auggie-users",
118-
# Item={
119-
# 'botToken': {'S': 'null'},
120-
# 'currentMessages': {'N': "0"},
121-
# 'maxMessages': {'N': "0"},
122-
# 'email': {'S': '{}:{}'.format(email, team_id)},
123-
# 'host': {'S': 'null'},
124-
# 'interestedGroups': {'L': []},
125-
# 'interestedRepos': {'L': []},
126-
# 'interestedInsightTypes': {'L': []},
127-
# 'teamID': {'S': team_id},
128-
# 'thread': {'S': 'null'},
129-
# 'userID': {'S': user_response['user']['id']}
130-
# }
131-
# )
132-
133-
# # users_response = webclient.users_list()
134-
# # for user in users_response["members"]:
135-
# # if "api_app_id" in user["profile"] and user["profile"]["api_app_id"] == "ASQKB8JT0":
136-
# # im_response = webclient.conversations_open(
137-
# # users=user["id"]
138-
# # )
139-
# # print("Hopefully IM is opened")
140-
# # channel = im_response["channel"]["id"]
141-
142-
# # message_response = webclient.chat_postMessage(
143-
# # channel=channel,
144-
# # text="what repos?",
145-
# # as_user="true")
146-
# # print(message_response)
147-
148-
# # ts = message_response["ts"]
149-
# # webclient.chat_delete(
150-
# # channel=channel,
151-
# # ts=ts
152-
# # )
153-
154-
# response = client.get_item(
155-
# TableName="auggie-users",
156-
# Key={
157-
# "email": {"S": '{}:{}'.format(email, team_id)}
158-
# }
159-
# )
160-
161-
# user = response['Item']
162-
# print(user)
163-
164-
# filteredUser = {
165-
# "interestedRepos": user["interestedRepos"],
166-
# "interestedGroups": user["interestedGroups"],
167-
# "host": user["host"],
168-
# "maxMessages": user["maxMessages"],
169-
# "interestedInsights": user["interestedInsightTypes"]
170-
# }
171-
172-
# user_body = json.dumps({
173-
# 'team_id': team_id,
174-
# 'email': email,
175-
# 'user': filteredUser
176-
# })
177-
178-
# print(user_body)
179-
180-
# return user_body
181-
# else:
182-
# return data
183-
184-
# #@annotate(tag='update-auggie-user-tracking')
185-
# def update_tracking(metric, body):
186-
# profile_name = 'collectoss'
187-
# if os.environ.get('AUGUR_IS_PROD'):
188-
# profile_name = 'default'
189-
# client = boto3.Session(region_name='us-east-1', profile_name=profile_name).client('dynamodb')
190-
# response = client.update_item(
191-
# TableName="auggie-users",
192-
# Key={
193-
# "email": {"S": '{}:{}'.format(body["email"], body["teamID"])}
194-
# },
195-
# UpdateExpression="SET interestedGroups = :valGroup, interestedRepos = :valRepo, maxMessages = :valMax, host = :valHost, interestedInsightTypes = :valInterestedInsights",
196-
# ExpressionAttributeValues={
197-
# ":valGroup": {
198-
# "L": body["groups"]
199-
# },
200-
# ":valRepo": {
201-
# "L": body["repos"]
202-
# },
203-
# ":valMax": {
204-
# "N": body["maxMessages"]
205-
# },
206-
# ":valHost": {
207-
# "S": body["host"]
208-
# },
209-
# ":valInterestedInsights": {
210-
# "L": body["insightTypes"]
211-
# }
212-
# },
213-
# ReturnValues="ALL_NEW"
214-
# )
215-
216-
# updated_values = response['Attributes']
217-
218-
# filtered_values = {
219-
# "interestedRepos": updated_values["interestedRepos"],
220-
# "interestedGroups": updated_values["interestedGroups"],
221-
# "host": updated_values["host"]
222-
# }
223-
224-
# return filtered_values
225-
226-
227-
# #@annotate(tag='get-auggie-user')
228-
# def get_auggie_user(metric, body):
229-
# profile_name = 'collectoss'
230-
# if os.environ.get('AUGUR_IS_PROD'):
231-
# profile_name = 'default'
232-
# client = boto3.Session(region_name='us-east-1', profile_name=profile_name).client('dynamodb')
233-
# response = client.get_item(
234-
# TableName="auggie-users",
235-
# Key={
236-
# "email": {"S":'{}:{}'.format(body["email"],body["teamID"])}
237-
# }
238-
# )
239-
# user = response['Item']
240-
241-
# filteredUser = {
242-
# "interestedRepos":user["interestedRepos"],
243-
# "interestedGroups":user["interestedGroups"],
244-
# "host":user["host"]
245-
# }
246-
247-
# return filteredUser
248-
249-
25025
@app.route('/auggie/get_user', methods=['POST'])
25126
def get_auggie_user():
25227
# arg = [request.json]

collectoss/application/db/engine.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from sqlalchemy import create_engine, event
99
from sqlalchemy.engine import Engine
1010
from collectoss.application.environment import SystemEnv
11-
from collectoss.application.db.util import catch_operational_error
12-
1311

1412
def parse_database_string(db_string: str) -> tuple[str,str, str, str, str]:
1513
"""Parse database string into the following components:
@@ -147,25 +145,4 @@ def create_database_engine(self, **kwargs):
147145

148146
return create_database_engine(db_conn_string, **kwargs)
149147

150-
class EngineConnection():
151-
152-
def __init__(self, engine):
153-
self.connection = self.get_connection(engine)
154-
155-
def __enter__(self):
156-
return self.connection
157-
158-
def __exit__(self, exception_type, exception_value, exception_traceback):
159-
160-
self.connection.close()
161-
162-
def get_connection(self, engine):
163-
164-
func = engine.connect
165-
166-
return catch_operational_error(func)
167-
168-
169-
170-
171148

collectoss/application/db/util.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,6 @@ def execute_session_query(query, query_type="all"):
4242

4343
return catch_operational_error(func)
4444

45-
46-
47-
def convert_orm_list_to_dict_list(result):
48-
new_list = []
49-
50-
for row in result:
51-
row_dict = row.__dict__
52-
try:
53-
del row_dict['_sa_instance_state']
54-
except:
55-
pass
56-
57-
new_list.append(row_dict)
58-
59-
return new_list
60-
61-
62-
6345
def convert_type_of_value(config_dict, logger=None):
6446

6547
data_type = config_dict["type"]

collectoss/tasks/git/dependency_libyear_tasks/libyear_util/pypi_parser.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ def map_dependencies_pipfile(packages, type):
9696
deps.append(Dict)
9797
return deps
9898

99-
100-
#def parse_pipfile(file_handle):
101-
# manifest = tomllib.load(file_handle)
102-
# return map_dependencies_pipfile(manifest['packages'],'runtime') + #map_dependencies_pipfile(manifest['dev-packages'], 'develop')
103-
## Erro handling Means that the parse_pipfile(...) old function is assuming the presence of a dev-packages key in the parsed Pipfile, but that key does not exist in some cases.
104-
10599
def parse_pipfile(file_handle):
106100
try:
107101
manifest = tomllib.load(file_handle)

collectoss/tasks/git/util/facade_worker/facade_worker/repofetch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from sqlalchemy.orm.exc import NoResultFound
3535
from collectoss.application.db.models.data import *
3636
from collectoss.application.db.models.operations import CollectionStatus
37-
from collectoss.application.db.util import execute_session_query, convert_orm_list_to_dict_list
37+
from collectoss.application.db.util import execute_session_query
3838
from collectoss.application.db.lib import execute_sql, get_repo_by_repo_git
3939
from typing_extensions import deprecated
4040

collectoss/tasks/github/util/gh_graphql_entities.py

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -531,64 +531,3 @@ def get_pull_requests_collection(self):
531531
pull_request_collection = GraphQlPageCollection(query, self.keyAuth,self.logger,bind=params,repaginateIfIncomplete=repaginateIfIncomplete)
532532

533533
return pull_request_collection
534-
535-
536-
537-
class PullRequest():
538-
def __init__(self, logger, key_auth, owner, repo, number):
539-
540-
self.keyAuth = key_auth
541-
self.url = "https://api.github.com/graphql"
542-
543-
self.logger = logger
544-
545-
self.owner = owner
546-
self.repo = repo
547-
self.number = number
548-
549-
def get_reviews_collection(self):
550-
551-
query = """
552-
query MyQuery($repo: String!, $owner: String!,$number: Int!, $numRecords: Int!, $cursor: String) {
553-
repository(name: $repo, owner: $owner) {
554-
pullRequest(number: $number) {
555-
reviews(first: $numRecords, after: $cursor) {
556-
edges {
557-
node {
558-
author {
559-
login
560-
url
561-
}
562-
body
563-
bodyHTML
564-
bodyText
565-
id
566-
createdAt
567-
url
568-
}
569-
}
570-
totalCount
571-
pageInfo {
572-
hasNextPage
573-
endCursor
574-
}
575-
}
576-
}
577-
}
578-
}
579-
"""
580-
581-
#Values specifies the dictionary values we want to return as the issue collection.
582-
#e.g. here we get the reviews of the specified repository by pr.
583-
values = ("repository","pullRequest","reviews")
584-
585-
params = {
586-
'owner' : self.owner,
587-
'repo' : self.repo,
588-
'number' : self.number,
589-
'values' : values
590-
}
591-
592-
review_collection = GraphQlPageCollection(query, self.keyAuth, self.logger,bind=params)
593-
594-
return review_collection

collectoss/tasks/github/util/github_data_access.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,3 @@ def __add_query_params(self, url: str, additional_params: dict) -> str:
292292
updated_query = urlencode(merged_params, doseq=True)
293293
# _replace() is how you can create a new NamedTuple with a changed field
294294
return url_components._replace(query=updated_query).geturl()
295-
296-
297-
298-
299-
300-
301-
302-
303-
304-

0 commit comments

Comments
 (0)