Skip to content

Commit

Permalink
Merge pull request #2464 from chaoss/dev
Browse files Browse the repository at this point in the history
Release 0.51.1
  • Loading branch information
sgoggins committed Aug 13, 2023
2 parents 6e232d2 + f8f546b commit 03e5cf8
Show file tree
Hide file tree
Showing 27 changed files with 539 additions and 126,868 deletions.
4 changes: 2 additions & 2 deletions README.md
@@ -1,4 +1,4 @@
# Augur NEW Release v0.51.0
# Augur NEW Release v0.51.1

[![first-timers-only](https://img.shields.io/badge/first--timers--only-friendly-blue.svg?style=flat-square)](https://www.firsttimersonly.com/) We follow the [First Timers Only](https://www.firsttimersonly.com/) philosophy of tagging issues for first timers only, and walking one newcomer through the resolution process weekly. [You can find these issues tagged with "first timers only" on our issues list.](https://github.com/chaoss/augur/labels/first-timers-only).

Expand All @@ -8,7 +8,7 @@
### [If you want to jump right in, updated docker build/compose and bare metal installation instructions are available here](docs/new-install.md)


Augur is now releasing a dramatically improved new version to the main branch. It is also available here: https://github.com/chaoss/augur/releases/tag/v0.51.0
Augur is now releasing a dramatically improved new version to the main branch. It is also available here: https://github.com/chaoss/augur/releases/tag/v0.51.1
- The `main` branch is a stable version of our new architecture, which features:
- Dramatic improvement in the speed of large scale data collection (100,000+ repos). All data is obtained for 100k+ repos within 2 weeks.
- A new job management architecture that uses Celery and Redis to manage queues, and enables users to run a Flower job monitoring dashboard
Expand Down
38 changes: 13 additions & 25 deletions augur/api/routes/user.py
Expand Up @@ -2,38 +2,26 @@
"""
Creates routes for user functionality
"""
from augur.api.routes import AUGUR_API_VERSION

import logging
import requests
import os
import base64
import time
import secrets
import pandas as pd
from flask import request, Response, jsonify, session
from flask import request, jsonify, session
from flask_login import login_user, logout_user, current_user, login_required
from werkzeug.security import check_password_hash
from sqlalchemy.sql import text
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm.exc import NoResultFound
from augur.application.db.session import DatabaseSession
from augur.tasks.github.util.github_task_session import GithubTaskSession
from augur.util.repo_load_controller import RepoLoadController
from augur.api.util import api_key_required
from augur.api.util import ssl_required

from augur.application.db.models import User, UserRepo, UserGroup, UserSessionToken, ClientApplication, RefreshToken
from augur.application.config import get_development_flag
from augur.application.db.models import User, UserSessionToken, RefreshToken
from augur.tasks.init.redis_connection import redis_connection as redis
from ..server import app, engine

logger = logging.getLogger(__name__)
current_user: User = current_user
Session = sessionmaker(bind=engine)

from augur.api.routes import AUGUR_API_VERSION


@app.route(f"/{AUGUR_API_VERSION}/user/validate", methods=['POST'])
@ssl_required
def validate_user():
Expand All @@ -51,7 +39,7 @@ def validate_user():
return jsonify({"status": "Invalid username"})

checkPassword = check_password_hash(user.login_hashword, password)
if checkPassword == False:
if not checkPassword:
return jsonify({"status": "Invalid password"})


Expand Down Expand Up @@ -89,9 +77,9 @@ def generate_session(application):
code = request.args.get("code") or request.form.get("code")
if not code:
return jsonify({"status": "Missing argument: code"}), 400

grant_type = request.args.get("grant_type") or request.form.get("grant_type")

if "code" not in grant_type:
return jsonify({"status": "Invalid grant type"})

Expand Down Expand Up @@ -131,25 +119,25 @@ def refresh_session(application):

if not refresh_token_str:
return jsonify({"status": "Missing argument: refresh_token"}), 400

if request.args.get("grant_type") != "refresh_token":
return jsonify({"status": "Invalid grant type"})

with DatabaseSession(logger) as session:

refresh_token = session.query(RefreshToken).filter(RefreshToken.id == refresh_token_str).first()
if not refresh_token:
return jsonify({"status": "Invalid refresh token"})
return jsonify({"status": "Invalid refresh token"}), 400

if refresh_token.user_session.application != application:
return jsonify({"status": "Invalid application"})
return jsonify({"status": "Invalid application"}), 400

user_session = refresh_token.user_session
user = user_session.user

new_user_session_token = UserSessionToken.create(session, user.user_id, user_session.application.id).token
new_refresh_token_id = RefreshToken.create(session, new_user_session_token).id

session.delete(refresh_token)
session.delete(user_session)
session.commit()
Expand Down Expand Up @@ -327,11 +315,11 @@ def group_repos():

result_dict = result[1]
if result[0] is not None:

for repo in result[0]:
repo["base64_url"] = str(repo["base64_url"].decode())

result_dict.update({"repos": result[0]})
result_dict.update({"repos": result[0]})

return jsonify(result_dict)

Expand Down Expand Up @@ -436,7 +424,7 @@ def toggle_user_group_favorite():
Returns
-------
dict
A dictionairy with key of 'status' that indicates the success or failure of the operation
A dictionary with key of 'status' that indicates the success or failure of the operation
"""
group_name = request.args.get("group_name")

Expand Down
2 changes: 1 addition & 1 deletion augur/api/view/augur_view.py
Expand Up @@ -29,7 +29,7 @@ def page_not_found(error):
if AUGUR_API_VERSION in str(request.path):
return jsonify({"status": "Not Found"}), 404

return render_template('index.j2', title='404', api_url=getSetting('serving')), 404
return render_template('index.j2', title='404'), 404

@app.errorhandler(405)
def unsupported_method(error):
Expand Down
52 changes: 0 additions & 52 deletions augur/api/view/init.py
Expand Up @@ -8,8 +8,6 @@
# load configuration files and initialize globals
configFile = Path(env.setdefault("CONFIG_LOCATION", "config.yml"))

version = {"major": 0, "minor": 0.1, "series": "Alpha"}

report_requests = {}
settings = {}

Expand All @@ -22,7 +20,6 @@ def init_settings():
settings["pagination_offset"] = 25
settings["reports"] = "reports.yml"
settings["session_key"] = secrets.token_hex()
settings["version"] = version

def write_settings(current_settings):
current_settings["caching"] = str(current_settings["caching"])
Expand All @@ -33,55 +30,6 @@ def write_settings(current_settings):
with open(configFile, 'w') as file:
yaml.dump(current_settings, file)

""" ----------------------------------------------------------------
"""
def version_check(current_settings):
def to_version_string(version_object):
if version_object is None:
return "Undefined_version"
return f'{version_object["major"]}-{version_object["minor"]}-{version_object["series"]}'

def update_from(old):
if old == None:
if "pagination_offset" not in current_settings:
current_settings["pagination_offset"] = current_settings.pop("paginationOffset")
if "session_key" not in current_settings:
current_settings["session_key"] = secrets.token_hex()

else:
raise ValueError(f"Updating from {to_version_string(old)} to {to_version_string(version)} is unsupported")

current_settings["version"] = version
write_settings(current_settings)
logger.info(f"Configuration updated from {to_version_string(old)} to {to_version_string(version)}")

def compare_versions(old, new):
if old["major"] < new["major"]:
return -1, old["series"] == new["series"]
elif old["major"] > new["major"]:
return 1, old["series"] == new["series"]
elif old["minor"] < new["minor"]:
return -1, old["series"] == new["series"]
elif old["minor"] > new["minor"]:
return 1, old["series"] == new["series"]
return 0, old["series"] == new["series"]

if "version" not in current_settings:
update_from(None)

version_diff = compare_versions(current_settings["version"], version)

if current_settings["version"] == version:
return
elif version_diff[0] == -1:
update_from(current_settings["version"])
elif version_diff[0] == 1:
raise ValueError("Downgrading configuration versions is unsupported: " +
f"from {to_version_string(current_settings['version'])} to {to_version_string(version)}")

global settings
settings = current_settings

# default reports definition
reports = {
"pull_request_reports":[
Expand Down
36 changes: 0 additions & 36 deletions augur/api/view/routes.py
Expand Up @@ -79,11 +79,7 @@ def repo_table_view():
else:
data = get_all_repos(page = page, sort = sorting, direction = direction, search=query)[0]
page_count = (get_all_repos_count(search = query)[0] or 0) // pagination_offset

#if not cacheFileExists("repos.json"):
# return renderLoading("repos/views/table", query, "repos.json")

# return renderRepos("table", query, data, sorting, rev, page, True)
return render_module("repos-table", title="Repos", repos=data, query_key=query, activePage=page, pages=page_count, offset=pagination_offset, PS="repo_table_view", reverse = rev, sorting = sorting)

""" ----------------------------------------------------------------
Expand All @@ -102,31 +98,6 @@ def repo_card_view():

return renderRepos("card", query, data, filter = True)

""" ----------------------------------------------------------------
groups:
This route returns the groups table view, listing all the current
groups in the backend
"""
# @app.route('/groups')
# @app.route('/groups/<group>')
# def repo_groups_view(group=None):
# query = request.args.get('q')
# page = request.args.get('p')

# if(group is not None):
# query = group

# if(query is not None):
# buffer = []
# data = requestJson("repos")
# for repo in data:
# if query == str(repo["repo_group_id"]) or query in repo["rg_name"]:
# buffer.append(repo)
# return renderRepos("table", query, buffer, page = page, pageSource = "repo_groups_view")
# else:
# groups = requestJson("repo-groups")
# return render_template('index.html', body="groups-table", title="Groups", groups=groups, query_key=query, api_url=getSetting('serving'))

""" ----------------------------------------------------------------
status:
This route returns the status view, which displays information
Expand Down Expand Up @@ -346,13 +317,6 @@ def user_group_view(group = None):
page_count = current_user.get_group_repo_count(group, search = query)[0] or 0
page_count //= pagination_offset

# if not data:
# return render_message("Error Loading Group", "Either the group you requested does not exist, the group has no repos, or an unspecified error occurred.")

#if not cacheFileExists("repos.json"):
# return renderLoading("repos/views/table", query, "repos.json")

# return renderRepos("table", None, data, sort, rev, params.get("page"), True)
return render_module("user-group-repos-table", title="Repos", repos=data, query_key=query, activePage=params["page"], pages=page_count, offset=pagination_offset, PS="user_group_view", reverse = rev, sorting = params.get("sort"), group=group)

@app.route('/error')
Expand Down

0 comments on commit 03e5cf8

Please sign in to comment.