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

Develop #46

Merged
merged 8 commits into from
Aug 26, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: build docker
steps:
########## CHECK OUT REPO AND PRINT REPO INFO #######
- name: Checkout
- name: Checkout repo
uses: actions/checkout@v3
- name: Intro to job runner
run: |
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
name: test docker
steps:
########## CHECK OUT REPO AND PRINT REPO INFO #######
- name: Checkout
- name: Checkout repo
uses: actions/checkout@v3
######### DOCKER LOGIN AND PULL CUSTOM ACTION #############
- name: Docker Login and Pull
Expand All @@ -57,5 +57,5 @@ jobs:
${{ github.repository }}
tag:
${{ github.ref_name }}
- name: Run tests
run: docker run ghcr.io/${{ github.repository }}:${{ github.ref_name }} /bin/bash -c "coverage run manage.py test apps && coverage xml --data-file=.coverage && codecov --token=${{ secrets.codecov_token }} "
- name: Run tests in container
run: docker run ghcr.io/${{ github.repository }}:${{ github.ref_name }} /bin/bash -c "coverage run manage.py test apps "
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: test native
steps:
########## CHECK OUT REPO AND PRINT REPO INFO #######
- name: Checkout
- name: Checkout repo
uses: actions/checkout@v3
- name: Intro to job runner
run: |
Expand All @@ -22,10 +22,10 @@ jobs:
run: |
pip install pyfiglet
pip install -r requirements.txt
pyfiglet TEST LOCAL
- name: Run test local
pyfiglet Packges Downloaded
- name: Run coverage test local
run: coverage run manage.py test apps && coverage xml --data-file=.coverage
- name: codecov
- name: Upload to CodeCov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.codecov_token }} # not required for public repos
Expand Down
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ media

# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/
staticfiles/

### Django.Python Stack ###
# Byte-compiled / optimized / DLL files
Expand Down Expand Up @@ -172,4 +172,11 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# End of https://www.toptal.com/developers/gitignore/api/django
# End of https://www.toptal.com/developers/gitignore/api/django

#PyCharm
.idea/


#Mac
.DS_Store
1 change: 1 addition & 0 deletions apps/speedtester/utils/abstract_speedtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from loguru import logger

# Setup django to be able to access the settings file
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'refresher_config.settings')
django.setup()

Expand Down
37 changes: 37 additions & 0 deletions apps/speedtester/utils/abstract_tweepy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import tweepy
import os

import django
import speedtest
from django.db.utils import IntegrityError
from loguru import logger
import pytz
from django.db.models import Avg, Max, Min, Sum

# Setup django to be able to access the settings file
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'refresher_config.settings')
django.setup()

from apps.speedtester.models import ServersModel, SpeedtesterModel

# auth = tweepy.Client(
# bearer_token="",
# consumer_key="",
# consumer_secret="",
# access_token="",
# access_token_secret="")
#
# auth.create_tweet(text="First automated tweet via refresher")

from datetime import datetime, timedelta, time

today = datetime.now()
tomorrow = today + timedelta(1)
today_start = datetime.combine(today, time())
today_end = datetime.combine(tomorrow, time())

objs = SpeedtesterModel.objects.filter(created__lte=today_end, created__gte=today_start)
print(objs.aggregate(Avg('download'), Avg('upload')))
print(objs.aggregate(Max('download'), Max('upload')))
print(objs.aggregate(Min('download'), Min('upload')))

1 change: 1 addition & 0 deletions apps/speedtester/utils/function_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ def process_speedtest_test():
client = refresher_speedtest.get_client()

return speedtest_res, best, servers, client

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dj-database-url = "^0.5.0"
psycopg2-binary = "^2.9.3"
codecov = "^2.1.12"
whitenoise = "^6.2.0"
tweepy = "^4.10.0"

[tool.poetry.dev-dependencies]

Expand Down
3 changes: 1 addition & 2 deletions refresher_config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand Down
Loading