Skip to content

Commit

Permalink
Feature count refresh (#887) (#893)
Browse files Browse the repository at this point in the history
* Try to invalidate the project cache

* Refresh qgis project after commit layers.

* Fix test

* Fix test

* Fix test

* Remove version declaration

* Update qgis deploy

* Fix tests

* Test

* Fix test

* Fix test

* Fix tests

* Fix test

* Fix test

* Test

* Test

* test by qgis version

* Fix test with docker script

* Typo

---------

Co-authored-by: wlorenzetti <lorenzett@gis3w.it>
(cherry picked from commit b7ffb5d)

Co-authored-by: Walter Lorenzetti <lorenzetti@gis3w.it>
  • Loading branch information
github-actions[bot] and wlorenzetti authored Jul 3, 2024
1 parent 68823be commit 5e94481
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
9 changes: 4 additions & 5 deletions ci_scripts/Dockerfile.deps
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ RUN apt-get update && apt install -y \
xvfb

# PyQGIS latest version
RUN wget -qO - https://qgis.org/downloads/qgis-2022.gpg.key | \
gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/qgis-archive.gpg --import && \
chmod a+r /etc/apt/trusted.gpg.d/qgis-archive.gpg && \
echo "deb [arch=amd64] https://qgis.org/ubuntu jammy main" >> /etc/apt/sources.list && \
apt update && apt install -y python3-qgis qgis-server
RUN curl -sS https://download.qgis.org/downloads/qgis-archive-keyring.gpg > /etc/apt/keyrings/qgis-archive-keyring.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/qgis-archive-keyring.gpg] https://qgis.org/ubuntu jammy main" | \
tee /etc/apt/sources.list.d/qgis.list && \
apt-get update && apt-get install -y python3-qgis qgis-server

# Yarn

Expand Down
11 changes: 5 additions & 6 deletions ci_scripts/Dockerfile.ltr.deps
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ RUN apt-get update && apt install -y \
dirmngr \
xvfb

# PyQGIS 3.28
RUN wget -qO - https://qgis.org/downloads/qgis-2022.gpg.key | \
gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/qgis-archive.gpg --import && \
chmod a+r /etc/apt/trusted.gpg.d/qgis-archive.gpg && \
echo "deb [arch=amd64] https://qgis.org/ubuntu-ltr jammy main" >> /etc/apt/sources.list && \
apt update && apt install -y python3-qgis qgis-server
# PyQGIS
RUN curl -sS https://download.qgis.org/downloads/qgis-archive-keyring.gpg > /etc/apt/keyrings/qgis-archive-keyring.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/qgis-archive-keyring.gpg] https://qgis.org/ubuntu-ltr jammy main" | \
tee /etc/apt/sources.list.d/qgis.list && \
apt-get update && apt-get install -y python3-qgis qgis-server

# Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.latest.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Use QGIS latest release

version: "3"
services:
postgis:
image: g3wsuite/postgis:11.0-2.5
Expand Down
1 change: 0 additions & 1 deletion docker-compose.ltr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
services:
postgis:
image: g3wsuite/postgis:11.0-2.5
Expand Down
12 changes: 8 additions & 4 deletions g3w-admin/editing/api/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
EDITING_POST_DATA_UPDATED)
from editing.utils import LayerLock
from editing.utils.data import clear_session_for_uploaded_files
from qdjango.apps import get_qgs_project
from qdjango.apps import get_qgs_project, remove_project_from_cache
from qdjango.models import Layer
from qdjango.utils.data import QGIS_LAYER_TYPE_NO_GEOM
from qdjango.utils.validators import feature_validator
Expand Down Expand Up @@ -526,8 +526,8 @@ def response_commit_mode(self, request):
qgis_layer = self.metadata_layer.qgis_layer

# Get the project
qgis_project = get_qgs_project(Layer.objects.get(
pk=self.metadata_layer.layer_id).project.qgis_file.path)
project = Layer.objects.get(pk=self.metadata_layer.layer_id).project
qgis_project = get_qgs_project(project.qgis_file.path)

# Check if we have transaction groups activated
# Performs all operations in the editing buffer if we have transactions
Expand Down Expand Up @@ -653,9 +653,13 @@ def save_relation(post_relation_data, referencing_layer, ref_insert_ids) -> None
except:
pass

# clear file uploaded and reset session
# Clear file uploaded and reset session
clear_session_for_uploaded_files(request)

# Invalidate /api/config cache e invalidate QGIS project cache
project.invalidate_cache()
qgis_project.read(project.qgis_file.path)


def response_unlock_mode(self, request):
"""
Expand Down
8 changes: 6 additions & 2 deletions g3w-admin/qdjango/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
QGIS_FILE_MDAL = 'mdal_layer_qgis_322.qgs'
QGIS_FILE_EXPRESSION_DEFAULT = 'test_default_field_expression_322.qgs'

from qgis.core import Qgis


class QgisProjectTest(TestCase):

Expand Down Expand Up @@ -169,7 +171,8 @@ def test_layers(self):
self.assertTrue(layer.isVisible)
self.assertEqual(layer.srid, 4030)
self.assertEqual(layer.editOptions, 1)
self.assertEqual(layer.extent, 'POLYGON((-31.26574700000000462 32.3974759999999975, 69.07032000000000949 32.3974759999999975, 69.07032000000000949 81.85736800000000812, -31.26574700000000462 81.85736800000000812, -31.26574700000000462 32.3974759999999975))')
if Qgis.QGIS_VERSION_INT < 33800:
self.assertEqual(layer.extent, 'POLYGON((-31.26574700000000462 32.3974759999999975, 69.07032000000000949 32.3974759999999975, 69.07032000000000949 81.85736800000000812, -31.26574700000000462 81.85736800000000812, -31.26574700000000462 32.3974759999999975))')

# important check datasource, main for shp and raster data
# --------------------------------------------------------
Expand Down Expand Up @@ -260,7 +263,8 @@ def test_layers(self):
if layer.layerId == 'cities10000eu20171228095720113':

# check extent
self.assertEqual(layer.extent, 'POLYGON((-9.71666669999999932 35.00999999999999801, 57.35194440000000071 35.00999999999999801, 57.35194440000000071 69.96666670000000465, -9.71666669999999932 69.96666670000000465, -9.71666669999999932 35.00999999999999801))')
if Qgis.QGIS_VERSION_INT < 33800:
self.assertEqual(layer.extent, 'POLYGON((-9.71666669999999932 35.00999999999999801, 57.35194440000000071 35.00999999999999801, 57.35194440000000071 69.96666670000000465, -9.71666669999999932 69.96666670000000465, -9.71666669999999932 35.00999999999999801))')

# check editorlayout
# --------------------------------------------------------
Expand Down
10 changes: 6 additions & 4 deletions run_docker_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# mounted as /code in the container

# Get options paramenter
QGSV="322"
QGSV="ltr"
MOD="build"

usage() { # Function: Print a help message.
Expand All @@ -22,8 +22,8 @@ while getopts ":q:m:" options; do
q)
QGSV=${OPTARG}

if [[ $QGSV != "322" && $QGSV != "latest" ]] ; then
echo "Error: QGIS VERSION can be one of '322', 'latest'." >/dev/stderr
if [[ $QGSV != "ltr" && $QGSV != "latest" ]] ; then
echo "Error: QGIS VERSION can be one of 'ltr', 'latest'." >/dev/stderr
exit_abnormal
exit 1
fi
Expand Down Expand Up @@ -75,7 +75,7 @@ $DOCKER_COMMAND cp . g3w-suite:/code/

echo "Execute pip3 install requirements"
echo "---------------------------------"
$DOCKER_COMMAND exec g3w-suite sh -c "cd /code/ && python3 -m pip install pip==20.0.2 && pip3 install -r requirements_docker.txt && pip3 install -r requirements_huey.txt"
$DOCKER_COMMAND exec g3w-suite sh -c "cd /code/ && pip3 install -r requirements_docker.txt && pip3 install -r requirements_huey.txt"

$DOCKER_COMMAND exec g3w-suite sh -c "cd /code/ && pip3 install -r g3w-admin/caching/requirements.txt"

Expand Down Expand Up @@ -117,6 +117,8 @@ if [ $MOD == "test" ]; then

$DOCKER_COMMAND exec g3w-suite sh -c "cd /code/g3w-admin && python3 manage.py test qtimeseries"

$DOCKER_COMMAND exec g3w-suite sh -c "cd /code/g3w-admin && python3 manage.py test about"

else
$DOCKER_COMMAND exec g3w-suite bash
fi
Expand Down

0 comments on commit 5e94481

Please sign in to comment.