Skip to content
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
24 changes: 24 additions & 0 deletions .github/workflows/django-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint Django Project

on: [pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff==0.0.285

- name: Run linter with auto-fix
run: |
ruff check --fix . --format=github
2 changes: 1 addition & 1 deletion logicway/database/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .database import SessionLocal

8 changes: 5 additions & 3 deletions logicway/database/load_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ def get_existing_ids(session, model_class, id_column_name):
inspector = inspect(model_class)
primary_key_column = inspector.primary_key[0]
if not primary_key_column.name == id_column_name:
print(f"Warning: id_column_name '{id_column_name}' does not match PK '{primary_key_column.name}' for {model_class.__name__}. Ensure this is intended.")
print(f"Warning: id_column_name '{id_column_name}' "
f"does not match PK '{primary_key_column.name}' "
f"for {model_class.__name__}. Ensure this is intended.")

existing_ids_query = session.query(getattr(model_class, id_column_name)).all()
existing_ids = {str(id_tuple[0]) for id_tuple in existing_ids_query if id_tuple[0] is not None}
Expand All @@ -147,7 +149,7 @@ def get_existing_ids(session, model_class, id_column_name):
return set()


def insert_data_bulk(data, model_class, session, message, column_mapping=None, batch_size=1000): # Уменьшил batch_size для отладки, можно вернуть 10000
def insert_data_bulk(data, model_class, session, message, column_mapping=None, batch_size=1000):
objects = []
skipped_existing = 0

Expand All @@ -164,7 +166,7 @@ def insert_data_bulk(data, model_class, session, message, column_mapping=None, b
break
if csv_col_for_pk:
id_attr_name_in_model_for_check = pk_model_attr
pk_values_in_df = data[csv_col_for_pk].dropna().astype(str).unique()
#pk_values_in_df = data[csv_col_for_pk].dropna().astype(str).unique()
existing_ids = get_existing_ids(session, model_class, id_attr_name_in_model_for_check)


Expand Down
3 changes: 2 additions & 1 deletion logicway/database/tests/AJAX_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def get_route_data(url):
#rint(f"Skipping route with invalid route_id: {route_id}")
continue

if route_id in ["T2", "122", "162", "196", "216", "220", "226", "484", "490", "494", "561", "826", "881", "911"]:
if route_id in ["T2", "122", "162", "196", "216", "220", "226",
"484", "490", "494", "561", "826", "881", "911"]:
#print(f"Skipping direction 1 for route {route_id}")
direction_to_test = [direction[0]]
else:
Expand Down
1 change: 0 additions & 1 deletion logicway/database/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
import logicway
2 changes: 1 addition & 1 deletion logicway/database/tests/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.conf import settings


os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'logicway.logicway.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'logicway.logicway.settings.dev')
django.setup()

def test_url_import():
Expand Down
2 changes: 1 addition & 1 deletion logicway/logicway/settings/dev.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .base import *
from .base import * # noqa: F401

DEBUG = True

Expand Down
7 changes: 5 additions & 2 deletions logicway/logicway/settings/prod.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from .base import *
from .base import * # noqa: F401

DEBUG = False

ALLOWED_HOSTS.append('.taile241c6.ts.net')
if ALLOWED_HOSTS:
ALLOWED_HOSTS.append('.taile241c6.ts.net')
else:
ALLOWED_HOSTS = ['.taile241c6.ts.net']

CORS_ALLOWED_ORIGINS = [
"http://localhost:3000",
Expand Down
6 changes: 3 additions & 3 deletions logicway/scraper/scraper.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
#from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By

from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.service import Service as ChromeService
# from webdriver_manager.firefox import GeckoDriverManager
# from webdriver_manager.microsoft import EdgeChromiumDriverManager

Expand All @@ -16,7 +16,7 @@ def fetch_schedule_table(url):
options.add_argument("--disable-gpu")
options.add_argument("--disable-dev-shm-usage")

service = Service(ChromeDriverManager().install())
service = ChromeService(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)

try:
Expand Down
Loading