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 (all in 1) #314

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 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
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
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
5466190
fixed incorrect definition of horizontal line
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
73452c5
restore deletion of unnecessary workbook tabs
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
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
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
c4e3b7b
test outputs
why-not-try-calmer Jan 30, 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
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
test:
name: Test
runs-on: ubuntu-22.04
timeout-minutes: 15
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Start docker stack
Expand All @@ -44,4 +44,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: coverage_report.txt
path: testoutputs/coverage_report.txt
path: test_outputs/coverage_report.txt
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
.docker/tests/
.docker/tests/screenshot.png
.env
.vscode/
shell.nix
Pipfile
/test_outputs
*.nix
*.log
.idea
.coverage
.coverage
74 changes: 51 additions & 23 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,6 +30,7 @@
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


Expand Down Expand Up @@ -389,6 +391,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,6 +424,14 @@ 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()
Expand Down Expand Up @@ -515,34 +526,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
Loading
Loading