Skip to content

Commit

Permalink
Change generate activity default (#11)
Browse files Browse the repository at this point in the history
Only updates user activity on start and end of session to reduce database contention from highly parallel CI runs.
  • Loading branch information
klimburg authored Oct 14, 2023
1 parent eb3941d commit 217a437
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
sudo apt-get install libsasl2-dev python3-dev libldap2-dev libssl-dev
- name: Setup Python
uses: actions/setup-python@v2
with:
Expand Down
5 changes: 2 additions & 3 deletions flask_app/blueprints/api/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from flask_simple_api import SimpleAPI

from ... import activity
from ...utils.api_utils import (auto_render, requires_login,
requires_login_or_runtoken)
from ...utils.api_utils import auto_render, requires_login, requires_login_or_runtoken

blueprint = Blueprint('api', __name__, url_prefix='/api')

Expand All @@ -14,7 +13,7 @@
_api_info = {'endpoints': {}}


def API(func=None, require_real_login=False, generates_activity=True, require_login=True, version=1):
def API(func=None, require_real_login=False, generates_activity=False, require_login=True, version=1):
if func is None:
return functools.partial(API, require_real_login=require_real_login, generates_activity=generates_activity, require_login=require_login, version=version)

Expand Down
14 changes: 6 additions & 8 deletions flask_app/blueprints/api/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@
from flask_simple_api import error_abort
import flux
import requests

from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.exc import IntegrityError
from ...auth import get_or_create_user
from sqlalchemy.orm.exc import NoResultFound

from ...auth import get_or_create_user
from ...models import Session, SessionMetadata, Test, User, db
from ...search import get_orm_query_from_search_string
from ...models import Session, Test, db, SessionMetadata, User
from ...utils import get_current_time, statuses
from ...utils import get_current_time, profiling, statuses
from ...utils.api_utils import requires_role
from ...utils.subjects import get_or_create_subject_instance
from ...utils.users import has_role
from ...utils import profiling
from .blueprint import API

NoneType = type(None)

_DEFAULT_DELETE_GRACE_PERIOD_SECONDS = 60 * 60 * 24 * 30


@API(version=3)
@API(version=3, generates_activity=True)
def report_session_start(logical_id: str=None,
parent_logical_id: (NoneType, str)=None,
is_parent_session: bool=False,
Expand Down Expand Up @@ -109,7 +107,7 @@ def report_session_start(logical_id: str=None,
return returned


@API(version=2)
@API(version=2, generates_activity=True)
def report_session_end(id: int, duration: (int, NoneType)=None, has_fatal_errors: bool=False):
try:
session = Session.query.filter(Session.id == id).one()
Expand Down

0 comments on commit 217a437

Please sign in to comment.