Skip to content

Commit

Permalink
fix export end to handle several days
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienPeillet committed Dec 8, 2023
1 parent 5fb617d commit 1ceb79f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/gui/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,19 @@ def environmentLayerJoinTransectInfo(self, layer: QgsVectorLayer) -> None:

def addEndEffortFeature(self, layer: QgsVectorLayer) -> QgsVectorLayer:
effortGroupValues = layer.uniqueValues(
layer.fields().indexOf("_effortGroup")
layer.fields().indexOf("effortGroup")
)
layer.startEditing()
for effortGroupValue in effortGroupValues:
expr = QgsExpression(f"_effortGroup = {effortGroupValue}")
expr = QgsExpression(f"effortGroup = '{effortGroupValue}'")
request = QgsFeatureRequest(expr).addOrderBy("dateTime", False)
lastEffortFt = None
for lastEffortFt in layer.getFeatures(request):
break
if not lastEffortFt:
continue
expr = QgsExpression(
f"_effortGroup != {effortGroupValue} and "
f"effortGroup != '{effortGroupValue}' and "
f"status = '{StatusCode.display(StatusCode.BEGIN)}' and "
"dateTime > "
f"'{lastEffortFt['dateTime'].toPyDateTime().isoformat()}'"
Expand All @@ -310,7 +310,10 @@ def addEndEffortFeature(self, layer: QgsVectorLayer) -> QgsVectorLayer:
nextBegFt = None
for nextBegFt in layer.getFeatures(request):
break
if not nextBegFt:
if not nextBegFt or (
QDateTime(lastEffortFt["dateTime"]).date()
!= QDateTime(nextBegFt["dateTime"]).date()
):
nextBegFt = lastEffortFt
dt = QDateTime(nextBegFt["dateTime"]).addSecs(1)
else:
Expand Down

0 comments on commit 1ceb79f

Please sign in to comment.