-
Notifications
You must be signed in to change notification settings - Fork 846
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
Dev Release to Main #2665
Dev Release to Main #2665
Changes from 143 commits
f9ad429
a83fee5
577c4f8
6101789
cf8bf5b
08e7a31
cb7c632
b819f4d
dc3468b
8e36b39
eb42254
d94543d
415a433
a3f7bbd
1f987ed
ce17876
c21c8b3
9e023b1
631aea2
1423393
6531b9a
3a5bd3d
de5a69f
0799f8e
23335d0
abd3935
d18baa3
2b25d59
ca77029
63b6350
8446c04
9a0fb08
dccb8bc
ec0cfff
291feae
ccb0df7
12a204a
3c24954
59486fe
82c1a1b
8d4c1d7
d204673
e4d1375
574885e
a5d6522
57ea05f
33be983
31b7614
3a2a46d
2d4d149
4e104c5
9729bce
f10fb29
979e501
20bd29d
0dfcf9b
11340d4
286aa0c
1a187bc
9f635ba
de4217e
924a7ad
5a80cf2
57ce5de
ca6544d
daa4106
4d5b4b2
9793d44
29c31d5
0d0efb4
0e1dde5
dbe280a
b1a2ea6
a7c3195
1ca0855
b45db1e
f43a9fd
3c096d7
99e94c9
a023408
ba24d20
13eb449
05b53ec
ac3a815
cce213a
90add5e
f31308a
84b1a01
7370873
f9717c9
db449ca
ad0985a
0a43a50
6164e1c
eaeb4e9
562450e
d723825
e3e9a61
ae75bef
80d0c9d
c2d97ab
1c94076
9e7cc37
ef169be
888dd23
eb3887f
51c58e6
ce50ea3
c770c36
25ebabb
9ab76e7
b166fd6
29247b9
3aec047
fbcc02d
7057675
8ba2195
251e534
d03dca7
7f205db
9273baa
4cbfa15
fc3d13b
579dec0
59afa43
bd80a0e
91b84a8
2b242ef
5da3277
3e79270
21b5dd6
b61480b
79d74a1
3a1d89a
41ad59d
8fcc429
5099e31
f6f4f46
7433028
99ae0f3
205d0a3
3153f15
419f69a
5e86c55
54c2086
3667942
9ad969b
7302877
6224cfc
b8b2e94
f3f7fbe
f46ee05
dab348c
ea6d2d5
335864c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: "run-linting-checks" | ||
on: | ||
pull_request: | ||
branches: [main, dev] | ||
|
||
jobs: | ||
run-pylint: | ||
name: runner / pylint | ||
permissions: write-all | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: dciborow/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
reporter: github-pr-review | ||
level: warning | ||
glob_pattern: "**/*.py" | ||
filter_mode: "file" | ||
|
||
misspell: | ||
name: runner / misspell | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Highlight any misspellings in changes. | ||
uses: actions/checkout@v4 | ||
- name: misspell | ||
uses: reviewdog/action-misspell@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
locale: "US" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
""" | ||
Defines the api routes for the augur views | ||
""" | ||
import logging | ||
import math | ||
from flask import Flask, render_template, render_template_string, request, abort, jsonify, redirect, url_for, session, flash | ||
from sqlalchemy.orm.exc import NoResultFound | ||
from .utils import * | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
|
@@ -37,9 +41,9 @@ def root(path=""): | |
def logo(brand=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
if brand is None: | ||
return redirect(url_for('static', filename='img/augur_logo.png')) | ||
elif "augur" in brand: | ||
if "augur" in brand: | ||
return logo(None) | ||
elif "chaoss" in brand: | ||
if "chaoss" in brand: | ||
return redirect(url_for('static', filename='img/Chaoss_Logo_white.png')) | ||
return "" | ||
|
||
|
@@ -74,17 +78,15 @@ def repo_table_view(): | |
pagination_offset = config.get_value("frontend", "pagination_offset") | ||
|
||
if current_user.is_authenticated: | ||
data = load_repos_test(user = current_user, search = query, page = page, sort = sorting, direction = direction, source = "user") | ||
page_count = load_repos_test(user = current_user, search = query, count = True, source = "user") | ||
# data = current_user.get_repos(page = page, sort = sorting, direction = direction, search=query)[0] | ||
# page_count = (current_user.get_repo_count(search = query)[0] or 0) // pagination_offset | ||
data = current_user.get_repos(page = page, sort = sorting, direction = direction, search=query)[0] | ||
repos_count = (current_user.get_repo_count(search = query)[0] or 0) | ||
else: | ||
data = load_repos_test(search = query, page = page, sort = sorting, direction = direction) | ||
page_count = load_repos_test(search = query, count = True) | ||
# 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 | ||
data = get_all_repos(page = page, sort = sorting, direction = direction, search=query)[0] | ||
repos_count = (get_all_repos_count(search = query)[0] or 0) | ||
|
||
page_count = math.ceil(repos_count / pagination_offset) - 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
|
||
if not data.count(): | ||
if not data: | ||
data = None | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
""" | ||
Defines utility functions used by the augur api views | ||
""" | ||
from pathlib import Path | ||
from concurrent.futures import ThreadPoolExecutor | ||
from flask import render_template, flash, url_for, Flask | ||
from .init import init_logging | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
from .init import * | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
from ..server import app, db_session | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
from augur.application.config import AugurConfig | ||
|
@@ -9,11 +13,13 @@ | |
from augur.application.db.session import DatabaseSession | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
from augur.application.db.engine import DatabaseEngine | ||
from augur.application.db.models import User, Repo, RepoGroup, UserGroup, UserRepo | ||
from sqlalchemy import Column, Table, Integer, MetaData, or_, Label | ||
from sqlalchemy import Column, Table, Integer, MetaData, or_ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
from sqlalchemy.sql.operators import ilike_op, distinct_op | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
from sqlalchemy.sql.functions import coalesce | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
from augur.application.db.models.base import Base | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
|
||
from sqlalchemy.orm import Query | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
|
||
init_logging() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
|
||
from .init import logger | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
|
@@ -309,67 +315,5 @@ def render_module(module, **args): | |
args.setdefault("body", module) | ||
return render_template('index.j2', **args) | ||
|
||
""" ---------------------------------------------------------------- | ||
No longer used | ||
""" | ||
# My attempt at a loading page | ||
def renderLoading(dest, query, request): | ||
cache_files_requested.append(request) | ||
return render_template('index.j2', body="loading", title="Loading", d=dest, query_key=query, api_url=getSetting('serving')) | ||
|
||
with DatabaseEngine() as engine: | ||
augur_data_schema = MetaData(schema = "augur_data") | ||
augur_data_schema.reflect(bind = engine, views = True) | ||
|
||
commits_materialized_view: Table = augur_data_schema.tables["augur_data.api_get_all_repos_commits"] | ||
issues_materialized_view: Table = augur_data_schema.tables["augur_data.api_get_all_repos_issues"] | ||
|
||
""" ---------------------------------------------------------------- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
""" | ||
def load_repos_test(count = False, source = None, **kwargs): | ||
columns: list[Label] = [ | ||
Repo.repo_id.distinct().label("repo_id"), | ||
Repo.description.label("description"), | ||
Repo.repo_git.label("url"), | ||
coalesce(commits_materialized_view.columns.commits_all_time, 0).label("commits_all_time"), | ||
coalesce(issues_materialized_view.columns.issues_all_time, 0).label("issues_all_time"), | ||
RepoGroup.rg_name.label("rg_name"), | ||
Repo.repo_git.regexp_replace('.*github\.com\/[A-Za-z0-9 \- _]+\/([A-Za-z0-9 \- _ .]+)$', "\\1").label("repo_name"), | ||
Repo.repo_git.regexp_replace('.*github\.com\/([A-Za-z0-9 \- _]+)\/[A-Za-z0-9 \- _ .]+$', "\\1").label("repo_owner"), | ||
RepoGroup.repo_group_id.label("repo_group_id") | ||
] | ||
|
||
def get_colum_by_label(label: str)-> Label: | ||
for column in columns: | ||
if column.name == label: | ||
return column | ||
|
||
repos = db_session.query(*columns)\ | ||
.outerjoin(commits_materialized_view, Repo.repo_id == commits_materialized_view.columns.repo_id)\ | ||
.outerjoin(issues_materialized_view, Repo.repo_id == issues_materialized_view.columns.repo_id)\ | ||
.join(RepoGroup, Repo.repo_group_id == RepoGroup.repo_group_id) | ||
|
||
user: User = kwargs.get("user") | ||
if user: | ||
repos = repos.join(UserRepo, Repo.repo_id == UserRepo.repo_id)\ | ||
.join(UserGroup, UserGroup.group_id == UserRepo.group_id)\ | ||
.filter(UserGroup.user_id == user.user_id) | ||
|
||
search = kwargs.get("search") | ||
qkey = kwargs.get("query_key") or ["repo_name", "repo_owner"] | ||
if search: | ||
if isinstance(qkey, list) and len(qkey) > 0: | ||
repos = repos.filter(or_(ilike_op(get_colum_by_label(filter_column), f"%{search}%") for filter_column in qkey)) | ||
else: | ||
repos = repos.filter(ilike_op(get_colum_by_label(qkey), f"%{search}%")) | ||
|
||
page_size: int = kwargs.get("page_size") or 25 | ||
if count: | ||
c = repos.count() | ||
return math.ceil(c / page_size) - 1 | ||
|
||
page: int = kwargs.get("page") or 0 | ||
offset = page * page_size | ||
|
||
return repos.slice(offset, offset + page_size) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,9 +91,12 @@ def start(disable_collection, development, port): | |
logger.info("Deleting old task schedule") | ||
os.remove("celerybeat-schedule.db") | ||
|
||
celery_beat_process = None | ||
celery_command = "celery -A augur.tasks.init.celery_app.celery_app beat -l debug" | ||
celery_beat_process = subprocess.Popen(celery_command.split(" ")) | ||
with DatabaseSession(logger) as db_session: | ||
config = AugurConfig(logger, db_session) | ||
log_level = config.get_value("Logging", "log_level") | ||
celery_beat_process = None | ||
celery_command = f"celery -A augur.tasks.init.celery_app.celery_app beat -l {log_level.lower()}" | ||
celery_beat_process = subprocess.Popen(celery_command.split(" ")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
|
||
if not disable_collection: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pylint] reported by reviewdog 🐶
W0511: TODO: gitlab ensure the whole repo git is inserted so it can be found here (fixme)