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

P1-3 #321

Open
wants to merge 206 commits into
base: master
Choose a base branch
from
Open

P1-3 #321

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
9574b50
added a dialog for selecting/unselecting sections in reports
why-not-try-calmer Nov 20, 2023
f097c18
sections
why-not-try-calmer Nov 20, 2023
1d7dd66
added updated templates
why-not-try-calmer Nov 20, 2023
d1ff30b
Merge branch 'master' into 279-select-reports
why-not-try-calmer Nov 20, 2023
8e065f0
2-depth list
why-not-try-calmer Nov 21, 2023
197e8b3
partial instead of closure
why-not-try-calmer Nov 21, 2023
464a820
no line
why-not-try-calmer Nov 21, 2023
5c6e6d5
kwargs
why-not-try-calmer Nov 21, 2023
98257c6
filter out by date
why-not-try-calmer Nov 21, 2023
527993a
do not construct dispensable selectors
why-not-try-calmer Nov 21, 2023
9e37122
warns and aborts when Count objects are below 100 when generating report
why-not-try-calmer Nov 14, 2023
05499ea
push_info cannot be called from its parent django app, so let us fall…
why-not-try-calmer Nov 14, 2023
faf4418
added util and warning for missing days
why-not-try-calmer Nov 20, 2023
e368c7c
docstring
why-not-try-calmer Nov 20, 2023
e4c4c95
New definition of 'valid days in year'
why-not-try-calmer Nov 20, 2023
9b2f5d0
clean up
why-not-try-calmer Nov 23, 2023
1bac7d4
leftover
why-not-try-calmer Nov 23, 2023
bf2a14a
typos
why-not-try-calmer Nov 23, 2023
4e66666
adjusted expected test outcome
why-not-try-calmer Nov 27, 2023
4b31267
adjusted to only-count
why-not-try-calmer Nov 27, 2023
53ef6e4
ensure all items are there
why-not-try-calmer Nov 27, 2023
5cf52c5
add report
why-not-try-calmer Nov 27, 2023
076fc43
non-naive datetimes
why-not-try-calmer Nov 27, 2023
714e52c
more assertions
why-not-try-calmer Nov 27, 2023
8bbb241
removed unnecessary
why-not-try-calmer Nov 27, 2023
f9a9faf
remove files
why-not-try-calmer Nov 27, 2023
7b53124
type hints, format
why-not-try-calmer Nov 28, 2023
911cddf
moving CL_LV data to Data_year
why-not-try-calmer Nov 28, 2023
7b6ea66
moved AN_TE to Data_hour
why-not-try-calmer Nov 28, 2023
9d1c4b8
gitignore
why-not-try-calmer Nov 28, 2023
ff4fd3c
Removing dead code and more type hints (#309)
why-not-try-calmer Dec 1, 2023
c3ac57d
test for precision
why-not-try-calmer Dec 1, 2023
3e03ede
checking for 3 decimals
why-not-try-calmer Dec 1, 2023
df44afa
---
why-not-try-calmer Dec 1, 2023
e2e91ec
__init__ helper function
why-not-try-calmer Dec 1, 2023
6bb7f47
test
why-not-try-calmer Dec 1, 2023
78ca3ba
Merge branch 'master' into 269-imprecise-columns-in-MD-hour-week
why-not-try-calmer Dec 1, 2023
f73827f
---
why-not-try-calmer Dec 1, 2023
e2afecc
---
why-not-try-calmer Dec 1, 2023
1a403f9
Merge branch 'master' into 268-missing-items-from-count-details
why-not-try-calmer Dec 1, 2023
fe48f73
Merge branch 'master' into 279-select-reports
why-not-try-calmer Dec 4, 2023
00606e0
format
why-not-try-calmer Dec 4, 2023
5a9805c
missing return
why-not-try-calmer Dec 4, 2023
46d13c2
fix extra line
why-not-try-calmer Dec 4, 2023
fc170a3
valid days
why-not-try-calmer Dec 4, 2023
5436d56
simplified
why-not-try-calmer Dec 4, 2023
4200557
update test
why-not-try-calmer Dec 4, 2023
4dcd90f
do not truncate
why-not-try-calmer Dec 5, 2023
bf1378b
a few fixes
why-not-try-calmer Dec 5, 2023
75b3b33
log
why-not-try-calmer Dec 5, 2023
417f206
fence off distinct() on 1-element queryset
why-not-try-calmer Dec 5, 2023
a416e6b
let's try importing all files (painfully slow)
why-not-try-calmer Dec 5, 2023
46891fb
restored 'utils.py'
why-not-try-calmer Dec 5, 2023
9629041
distinct
why-not-try-calmer Dec 5, 2023
0b39c6c
testouputs and 1 more test
why-not-try-calmer Dec 8, 2023
a7eb49c
Merge branch 'master' into 285-prepare-yearly-report
why-not-try-calmer Dec 8, 2023
141cb08
testing special cases
why-not-try-calmer Dec 8, 2023
c600e2c
---
why-not-try-calmer Dec 8, 2023
ce107a8
spcial cases passing
why-not-try-calmer Dec 8, 2023
8254b65
--
why-not-try-calmer Dec 11, 2023
e5a951e
---
why-not-try-calmer Dec 11, 2023
67d61d5
---
why-not-try-calmer Dec 11, 2023
c58a4f2
Revert "--"
why-not-try-calmer Dec 11, 2023
9110bef
fixed test
why-not-try-calmer Dec 11, 2023
7720a46
loading some test data and creating some outputs
why-not-try-calmer Nov 27, 2023
1324ce9
format
why-not-try-calmer Nov 27, 2023
6006d4a
assertion
why-not-try-calmer Nov 27, 2023
53987ac
renamed
why-not-try-calmer Nov 27, 2023
68e87c3
2 not 4 reports
why-not-try-calmer Dec 4, 2023
9e424b0
test and testdata
why-not-try-calmer Dec 4, 2023
043a156
correct values in Count
why-not-try-calmer Dec 4, 2023
e7ac7f1
---
why-not-try-calmer Dec 4, 2023
a59d26e
correct expected values in tests
why-not-try-calmer Dec 4, 2023
d3f6bcc
ensure that created files are a multiple of sections numbers
why-not-try-calmer Dec 4, 2023
8313408
more assertions
why-not-try-calmer Dec 4, 2023
8d46a0f
typo in yearly
why-not-try-calmer Dec 4, 2023
43df5e0
250 files
why-not-try-calmer Dec 4, 2023
2d3bddf
yearly reports use only 1 section
why-not-try-calmer Dec 5, 2023
af99aed
50 weeks
why-not-try-calmer Dec 5, 2023
a7e51ed
added 'sections_ids' optional parameter to issue extra files in yearl…
why-not-try-calmer Dec 5, 2023
d26d33d
found a few mistakes in original code, adding fixes
why-not-try-calmer Dec 5, 2023
2a53d8d
valuesqueryset removed
why-not-try-calmer Dec 5, 2023
c417317
restoring a few original lines
why-not-try-calmer Dec 5, 2023
31d960b
asserting qs
why-not-try-calmer Dec 7, 2023
5afa166
limit sections to those whose lanes match a countdetail
why-not-try-calmer Dec 11, 2023
358fec0
count_detail
why-not-try-calmer Dec 11, 2023
50695c9
---
why-not-try-calmer Dec 11, 2023
0c3d140
---
why-not-try-calmer Dec 11, 2023
70a7945
---
why-not-try-calmer Dec 11, 2023
1ed5cd9
guarding off section with only 1 lane in statistics
why-not-try-calmer Dec 11, 2023
93f96d9
fixed test
why-not-try-calmer Dec 12, 2023
a369037
docstring
why-not-try-calmer Dec 12, 2023
ded6307
type hints, isort
why-not-try-calmer Dec 12, 2023
e2d75c3
test
why-not-try-calmer Dec 12, 2023
f02aab5
report status
why-not-try-calmer Dec 12, 2023
c695fbb
more accurate aggregates and annotations
why-not-try-calmer Dec 18, 2023
6ef8c14
cleanup
why-not-try-calmer Dec 18, 2023
ba843a8
finalized aggregates
why-not-try-calmer Dec 18, 2023
4005265
small fix in vallues by day and month
why-not-try-calmer Dec 19, 2023
f730107
requirements
why-not-try-calmer Dec 19, 2023
12c2571
cleanup
why-not-try-calmer Dec 19, 2023
e321802
hline
why-not-try-calmer Dec 19, 2023
87e6183
Merge branch '267-updated-templates-in-yearly-report' into p1
why-not-try-calmer Dec 19, 2023
fd552cb
Merge branch '279-select-reports' into p1
why-not-try-calmer Dec 19, 2023
8bf24b4
Merge branch '285-prepare-yearly-report' into p1
why-not-try-calmer Dec 19, 2023
a2ff7f3
Merge branch '269-imprecise-columns-in-MD-hour-week' into p2
why-not-try-calmer Dec 19, 2023
c76a670
Merge branch '271-bike-yearly-report-columns' into p2
why-not-try-calmer Dec 19, 2023
4ceb000
Merge branch '268-missing-items-from-count-details' into p2
why-not-try-calmer Dec 19, 2023
16a61bb
Merge branch '278-missing-reports-beyond-1st-section' into p2
why-not-try-calmer Dec 19, 2023
621faaf
missing import
why-not-try-calmer Dec 19, 2023
b1c2272
idem
why-not-try-calmer Dec 19, 2023
02d9da6
typo
why-not-try-calmer Dec 19, 2023
5466190
fixed incorrect definition of horizontal line
why-not-try-calmer Dec 21, 2023
2d06273
fix type error when sections dists are 'NA'
why-not-try-calmer Dec 21, 2023
2fe5749
testdata out of package
why-not-try-calmer Dec 21, 2023
af0b298
test_outputs
why-not-try-calmer Dec 21, 2023
4e6f826
nicer formatting and alignment for checkboxes
why-not-try-calmer Dec 21, 2023
38677cf
typo
why-not-try-calmer Dec 21, 2023
dc4be31
test_outputs
why-not-try-calmer Dec 21, 2023
c3ca916
renamed section match
why-not-try-calmer Dec 21, 2023
6dfb83d
improvements
why-not-try-calmer Dec 21, 2023
cbc5203
no settings
why-not-try-calmer Dec 21, 2023
196d3f3
application does not allow to import django from core.utils
why-not-try-calmer Dec 21, 2023
432966e
no match for Python 3.9 on Windows
why-not-try-calmer Dec 22, 2023
d4438a7
format
why-not-try-calmer Dec 22, 2023
73452c5
restore deletion of unnecessary workbook tabs
why-not-try-calmer Dec 22, 2023
c79cdbb
to_time_aware removed from utils
why-not-try-calmer Dec 22, 2023
eee8d9b
format
why-not-try-calmer Dec 22, 2023
2d4ca53
deadcode, test_outputs
why-not-try-calmer Dec 22, 2023
28f7569
optional separator
why-not-try-calmer Dec 22, 2023
d7e6fe6
added missing distinct()
why-not-try-calmer Jan 7, 2024
7877873
handful of small fixes
why-not-try-calmer Jan 7, 2024
a73f052
wrong import
why-not-try-calmer Jan 7, 2024
6da2fd6
circular import
why-not-try-calmer Jan 7, 2024
818866e
-> utils
why-not-try-calmer Jan 7, 2024
332b016
catching KeyError s when removing spreadsheet's tabs
why-not-try-calmer Jan 7, 2024
4126882
improved removal from spreadsheet logic
why-not-try-calmer Jan 7, 2024
eedca66
settings has no need to be imported globally as it creates uninitaliz…
why-not-try-calmer Jan 7, 2024
0a04624
ci
why-not-try-calmer Jan 7, 2024
dae030e
Merge branch 'master' into p2
why-not-try-calmer Jan 7, 2024
4ff97bd
no validation
why-not-try-calmer Jan 7, 2024
0767bc1
call "tjmreset" upon deleting count data
why-not-try-calmer Jan 8, 2024
e73cc18
message for user
why-not-try-calmer Jan 8, 2024
b335937
Union instead of "|" for Python < 3.10
why-not-try-calmer Jan 9, 2024
e295c15
let's see if the tests agree with this
why-not-try-calmer Dec 19, 2023
2e5c585
versions
why-not-try-calmer Jan 10, 2024
62a1f0c
matrix settings
why-not-try-calmer Jan 10, 2024
6f19009
docs
why-not-try-calmer Jan 10, 2024
033f97d
update report
why-not-try-calmer Jan 15, 2024
a2f0ab3
checking output reports
why-not-try-calmer Jan 15, 2024
4da26d3
testing clean output of yearly MD reports (WIP)
why-not-try-calmer Jan 15, 2024
72d6206
fix aggregation for values_by_day_of_week
why-not-try-calmer Jan 15, 2024
cd3e939
fix tjm, add runs, to yearly bike report
why-not-try-calmer Jan 17, 2024
f12b84b
format
why-not-try-calmer Jan 17, 2024
f57f120
fixed "Data_class" tab
why-not-try-calmer Jan 17, 2024
7f5e913
improved values_by_day_and_direction, decoupled pulling data and rend…
why-not-try-calmer Jan 19, 2024
2b1bd1c
total_runs_by_hour_one_direction
why-not-try-calmer Jan 19, 2024
09a114d
tota_runs_by_hour_one_direction: writer
why-not-try-calmer Jan 19, 2024
938f6b9
Merge branch 'master' into p2
why-not-try-calmer Jan 22, 2024
5ee4cf2
Trafic by season
why-not-try-calmer Jan 8, 2024
a7281d3
linter
why-not-try-calmer Jan 8, 2024
7dbc525
settings locally imported
why-not-try-calmer Jan 8, 2024
1ad9ca2
adjusted on new specs
why-not-try-calmer Jan 8, 2024
564ba5a
updated template for MD; updated test data for MD; implemented season…
why-not-try-calmer Jan 9, 2024
3de6cce
...
why-not-try-calmer Jan 22, 2024
3a43743
count details by various criteria
why-not-try-calmer Jan 22, 2024
ff5a701
removing now unnecessary tests
why-not-try-calmer Jan 22, 2024
de4927a
test_outputs
why-not-try-calmer Jan 23, 2024
b22f8fd
moved test_data out of testing dir in view of a rebase onto master
why-not-try-calmer Jan 23, 2024
b793159
Merge branch 'master' into p2
why-not-try-calmer Jan 23, 2024
f10e205
Merge branch '301-upgrade-python-dependencies' into p3
why-not-try-calmer Jan 23, 2024
2305e7d
Merge branch '220-time-awareness-in-stats' into p3
why-not-try-calmer Jan 23, 2024
d525755
Merge branch '295-busiest-by-season' into p3
why-not-try-calmer Jan 23, 2024
b494dbd
Merge branch '282-update-tjm-on-deletion' into p3
why-not-try-calmer Jan 23, 2024
2172e88
missing envar from ci
why-not-try-calmer Jan 23, 2024
96e8edb
matrix in uploads
why-not-try-calmer Jan 23, 2024
a5ddf9a
import status to avoid surprises in tests
why-not-try-calmer Jan 23, 2024
76a9e67
gitignore
why-not-try-calmer Jan 23, 2024
b5005f3
trying out Pierre's patch
why-not-try-calmer Jan 30, 2024
d095163
trying out Pierre's patch
why-not-try-calmer Jan 30, 2024
266dbbc
Merge branch 'master' into p1
why-not-try-calmer Jan 30, 2024
b3c09d2
format
why-not-try-calmer Jan 30, 2024
5e65fe3
format
why-not-try-calmer Jan 30, 2024
02733d3
format
why-not-try-calmer Jan 30, 2024
f0736ee
---
why-not-try-calmer Jan 30, 2024
0ab261f
miscellaneous stats
why-not-try-calmer Jan 30, 2024
59404a8
---
why-not-try-calmer Jan 30, 2024
c4e3b7b
test outputs
why-not-try-calmer Jan 30, 2024
66801a6
implementation of yearly bike report miscellaneous statistics
why-not-try-calmer Jan 31, 2024
36c888b
---
why-not-try-calmer Jan 31, 2024
0111427
Merge branch 'p2' into p1-3
why-not-try-calmer Jan 31, 2024
505d766
Merge branch 'p3' into p1-3
why-not-try-calmer Jan 31, 2024
7d6bc91
---
why-not-try-calmer Jan 31, 2024
d1dbc16
format
why-not-try-calmer Jan 31, 2024
6115861
---
why-not-try-calmer Jan 31, 2024
306e9bd
---
why-not-try-calmer Jan 31, 2024
ad336aa
---
why-not-try-calmer Jan 31, 2024
0b4fef2
---
why-not-try-calmer Jan 31, 2024
756dfd5
Importing...
why-not-try-calmer Jan 31, 2024
f0c5264
release ci, longer timeout
why-not-try-calmer Jan 31, 2024
d769cc6
format
why-not-try-calmer Jan 31, 2024
bdbec4f
Union
why-not-try-calmer Feb 1, 2024
c9b0b69
format, py version
why-not-try-calmer Feb 1, 2024
c08c40e
---
why-not-try-calmer Feb 1, 2024
6e063c7
---
why-not-try-calmer Feb 1, 2024
7fb06e6
add tests for reports
why-not-try-calmer Feb 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
31 changes: 22 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ on:
pull_request:

jobs:
build_package_lint_check:
name: Build, package, lint, check
ensure_build_package:
name: Ensure build and package
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.9"
cache: "pip"
- name: Setup, build, install
run: |
Expand All @@ -29,19 +29,32 @@ jobs:
run: qgis-plugin-ci --no-validation package 'test'
- name: Lint
run: black . --check
- name: Check
run: pyright . > pyright_report.txt
continue-on-error: true
- uses: actions/upload-artifact@v4
with:
name: Pyright Report
path: pyright_report.txt

test:
name: Test
runs-on: ubuntu-22.04
timeout-minutes: 15
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
postgis_versions:
- 12-3.4
- 15-3.4
name: Test with PostGIS v. ${{ matrix.postgis_versions }}
steps:
- uses: actions/checkout@v4
- name: Start docker stack
run: docker compose up db -d
run: POSTGIS_VERSION=${{ matrix.postgis_versions }} docker compose up db -d
- name: Running tests
run: docker compose run qgis_tester
run: POSTGIS_VERSION=${{ matrix.postgis_versions }} docker compose run qgis_tester
- name: Upload test coverage report
uses: actions/upload-artifact@v4
with:
name: coverage_report.txt
path: testoutputs/coverage_report.txt
name: coverage_report-${{ matrix.postgis_versions }}.txt
path: test_outputs/coverage_report.txt
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.9"
cache: "pip"

- name: Setup
Expand All @@ -28,7 +28,7 @@ jobs:
id: package
run: |
latest_tag=${GITHUB_REF#refs/*/}
qgis-plugin-ci package $latest_tag
qgis-plugin-ci --no-validation package $latest_tag
echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT

- name: Upload binaries to release
Expand Down
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
**/__pycache__/
**/coverage_report.txt
test_outputs/
*.nix
*.log
.venv/
.vscode/
.docker/tests/
.docker/tests/screenshot.png
/test_outputs
.env
.vscode/
shell.nix
Pipfile
/test_outputs
*.nix
*.log
.idea
.coverage
.coverage
2 changes: 1 addition & 1 deletion comptages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def prepare_django(default_db=None, **additional_settings):
USE_TZ=True,
TIME_ZONE="Europe/Zurich",
SECRET_KEY="09n+dhzh+02+_#$!1+8h-&(s-wbda#0*2mrv@lx*y#&fzlv&l)",
**additional_settings
**additional_settings,
)
django.setup()

Expand Down
92 changes: 67 additions & 25 deletions comptages/comptages.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import pytz
from datetime import datetime, timedelta
from datetime import date, datetime, timedelta
from functools import partial

from qgis.PyQt.QtGui import QIcon
Expand All @@ -20,7 +20,8 @@
from comptages.core.filter_dialog import FilterDialog
from comptages.core.yearly_report_dialog import YearlyReportDialog
from comptages.core.delete_dialog import DeleteDialog
from comptages.core.utils import push_info
from comptages.core.utils import push_info, push_error
from comptages.core.statistics import get_valid_days
from comptages.datamodel import models
from comptages.core import importer, importer_task, report, report_task
from comptages.chart.chart_dialog import ChartDock
Expand All @@ -29,8 +30,11 @@
from comptages.report.yearly_report_bike import YearlyReportBike
from comptages.ics.ics_importer import IcsImporter
from comptages.ui.resources import *
from comptages.ui.select_reports import SelectSectionsToReport
from comptages.core import definitions

from django.core.management import call_command


class Comptages(QObject):
def __init__(self, iface):
Expand Down Expand Up @@ -389,6 +393,7 @@ def do_yearly_report_action(self):
selected_feature = next(layer.getSelectedFeatures())

section_id = selected_feature.attribute("id")
section = models.Section.objects.get(id=section_id)

classes = self.layers.get_classes_of_section(section_id)
dlg = YearlyReportDialog(self.iface)
Expand Down Expand Up @@ -421,13 +426,21 @@ def do_yearly_report_action(self):
Qgis.Info,
)

# Do not proceed unless the number of processed days exceeds 100 days
valid_days = get_valid_days(year, section)
if valid_days < 100:
push_error(
f"This section ({section_id}) lacks valid days for this year ({year}). Found only {valid_days} out of 100."
)
return

if clazz.startswith("SPCH-MD"):
yrb = YearlyReportBike(file_path, year, section_id)
yrb.run()
else:
self.tm.allTasksFinished.connect(
partial(self.all_tasks_finished, report)
) # FIXME `report` is a mystery.
partial(self.all_tasks_finished, "report")
)

# TODO: consider the chosed class too
self.tm.addTask(
Expand All @@ -440,6 +453,12 @@ def do_yearly_report_action(self):
)
# TODO: check if there are comptages for this section and year

QgsMessageLog.logMessage(
"{} - Generate yearly report action ended".format(datetime.now()),
"Comptages",
Qgis.Info,
)

def do_import_ics_action(self):
IcsImporter(self.layers)

Expand Down Expand Up @@ -515,34 +534,51 @@ def do_generate_report_action(self, count_id):
return

file_dialog = QFileDialog()
title = "Exporter un rapport"
path = self.settings.value("report_export_directory")
file_path = QFileDialog.getExistingDirectory(file_dialog, title, path)
mondays = list(report._mondays_of_count(count))
sections_ids = (
models.Section.objects.filter(lane__id_installation__count=count)
.distinct()
.values_list("id", flat=True)
)
report_selection_dialog = SelectSectionsToReport(
sections_ids=list(sections_ids), mondays=mondays
)

if not file_path:
if report_selection_dialog.exec_():
selected_sections_dates: dict[str, list[date]] = (
report_selection_dialog.get_inputs()
)
title = "Exporter un rapport"

path = self.settings.value("report_export_directory")
file_path = QFileDialog.getExistingDirectory(file_dialog, title, path)

if not file_path:
QgsMessageLog.logMessage(
"{} - Generate report action ended: No file_path given".format(
datetime.now()
),
"Comptages",
Qgis.Info,
)
return
QgsMessageLog.logMessage(
"{} - Generate report action ended: No file_path given".format(
datetime.now()
),
f"""
{datetime.now()} - Generate report action can really begin now for count {count.id} with file_path: {file_path}.
Selected sections and dates: {selected_sections_dates}
""",
"Comptages",
Qgis.Info,
)
return
QgsMessageLog.logMessage(
"{} - Generate report action can really begin now for count {} with file_path: {}".format(
datetime.now(), count.id, file_path
),
"Comptages",
Qgis.Info,
)

self.tm.allTasksFinished.connect(partial(self.all_tasks_finished, "report"))
self.tm.addTask(
report_task.ReportTask(
file_path=file_path,
count=count,
self.tm.allTasksFinished.connect(partial(self.all_tasks_finished, "report"))
self.tm.addTask(
report_task.ReportTask(
file_path=file_path,
count=count,
selected_sections_dates=selected_sections_dates,
)
)
)

def do_export_plan_action(self, count_id):
count = models.Count.objects.get(id=count_id)
Expand Down Expand Up @@ -640,6 +676,12 @@ def do_delete_data_action(self, count_id):
qs = qs.filter(status=definitions.IMPORT_STATUS_DEFINITIVE)

qs.delete()
call_command("tjmreset")
QgsMessageLog.logMessage(
"Les TJMs ont été réinitialisés; rouvrir cette fenêtre pour afficher les données actualisées!",
"Comptages",
Qgis.Info,
)

def enable_actions_if_needed(self):
"""Enable actions if the plugin is connected to the db
Expand Down
15 changes: 8 additions & 7 deletions comptages/core/importer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, Dict, Iterator, List, Optional
from typing import Callable, Iterator, Optional
import pytz
import os
from datetime import datetime, timedelta
Expand All @@ -9,8 +9,9 @@
from comptages.core.bulk_create_manager import BulkCreateManager


def simple_print_callback(progress):
print(f"Importing... {progress}%")
def simple_print_callback(progress: int):
if progress % 10 == 0:
print(f"Importing... {progress}%")


def import_file(file_path: str, count, callback_progress=simple_print_callback):
Expand Down Expand Up @@ -106,7 +107,7 @@ def _parse_and_write(
bulk_mgr.done()


def _parse_line_vbv1(line: str, **kwargs) -> Optional[List[Dict]]:
def _parse_line_vbv1(line: str, **kwargs) -> Optional[list[dict]]:
if line.startswith("* "):
return None

Expand Down Expand Up @@ -155,7 +156,7 @@ def _parse_line_vbv1(line: str, **kwargs) -> Optional[List[Dict]]:
return [parsed_line]


def _parse_line_mc(line: str, **kwargs) -> Optional[List[Dict]]:
def _parse_line_mc(line: str, **kwargs) -> Optional[list[dict]]:
if not line.startswith("20"):
return None

Expand All @@ -182,7 +183,7 @@ def _parse_line_mc(line: str, **kwargs) -> Optional[List[Dict]]:
parsed_line["category"] = int(line[51:54].strip())
parsed_line["height"] = ""
parsed_line["times"] = 1
except ValueError as e:
except ValueError:
# QgsMessageLog.logMessage(
# 'ValueError: {}'.format(e), 'Comptages', Qgis.Info)

Expand All @@ -192,7 +193,7 @@ def _parse_line_mc(line: str, **kwargs) -> Optional[List[Dict]]:
return [parsed_line]


def _parse_line_int2(line, **kwargs) -> Iterator[Optional[Dict]]:
def _parse_line_int2(line, **kwargs) -> Iterator[Optional[dict]]:
if line.startswith("* "):
return None

Expand Down
Loading
Loading