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

[GeoNature 2.14] error 500 'générer la liste des espèces' #61

Merged
merged 10 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 3 additions & 1 deletion backend/gn_module_zh/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from utils_flask_sqla.response import json_resp_accept_empty_list, json_resp

from .api_error import ZHApiError
from . import tasks # noqa: F401
from .forms import (
create_zh,
post_file_info,
Expand Down Expand Up @@ -81,6 +82,7 @@
get_main_picture_id,
get_user_cruved,
)
import gn_module_zh.tasks

blueprint = Blueprint("pr_zh", __name__, "./static", template_folder="templates")

Expand Down Expand Up @@ -810,8 +812,8 @@ def write_csv(id_zh):
tableName=blueprint.config[i]["table_name"],
schemaName=blueprint.config[i]["schema_name"],
filters={"id_zh": id_zh, "orderby": "id_zh"},
limit=100,
)
# TODO: change for limit=-1 when the next version of Utils-Flask-SQLAlchemy will be released
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ajouter le numéro de la version en question.

results = query.return_query().get("items", [])
current_date = dt.now()
if results:
Expand Down
7 changes: 4 additions & 3 deletions backend/gn_module_zh/conf_schema_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ class MapListConfig(Schema):

vertebrates_view_name = {
"schema_name": "pr_zh",
"table_name": "vertebrates",
"table_name": "vm_vertebrates",
"category": "vertebrates",
}

invertebrates_view_name = {
"schema_name": "pr_zh",
"table_name": "invertebrates",
"table_name": "vm_invertebrates",
"category": "invertebrates",
}

flora_view_name = {"schema_name": "pr_zh", "table_name": "flora", "category": "flora"}
flora_view_name = {"schema_name": "pr_zh", "table_name": "vm_flora", "category": "flora"}

# Name of the source of species data (tab5)
species_source_name = "GeoNature"
Expand Down Expand Up @@ -178,3 +178,4 @@ class GnModuleSchemaConf(Schema):
pdf_small_layer_number = fields.Integer(load_default=pdf_small_layer_number)
pdf_last_page_img = fields.String(load_default=pdf_last_page_img)
pdf_title = fields.String(load_default=pdf_title)
TAXON_VM_CRONTAB = fields.String(load_default="0 0,12 * * *")
2 changes: 1 addition & 1 deletion backend/gn_module_zh/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ def __check_if_rules(self):
raise ZHApiError(
message="no_rb_rules",
details="no existing rules for the river basin",
status_code=400,
edelclaux marked this conversation as resolved.
Show resolved Hide resolved
)
except ZHApiError:
raise
Expand Down Expand Up @@ -1235,7 +1236,6 @@ def get_all_hierarchy_fields(id_rb: int):
tableName="all_rb_rules",
schemaName="pr_zh",
filters={"id_rb": id_rb, "orderby": "name"},
limit=100000,
)

results = query.return_query()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""create_vm_taxon_refresh_function

Revision ID: 76e89c793961
Revises: c0c4748a597a
Create Date: 2024-04-16 08:12:41.346540

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "76e89c793961"
down_revision = "c0c4748a597a"
branch_labels = None
depends_on = None


def upgrade():
op.execute(
"""
CREATE OR REPLACE FUNCTION pr_zh.refresh_taxon_materialized_views()
RETURNS void
LANGUAGE plpgsql
AS $function$
BEGIN
REFRESH MATERIALIZED VIEW pr_zh.vm_vertebrates;
REFRESH MATERIALIZED VIEW pr_zh.vm_invertebrates;
REFRESH MATERIALIZED VIEW pr_zh.vm_flora;
END;
$function$
;
"""
)


def downgrade():
op.execute(
"""
DROP FUNCTION pr_zh.refresh_taxon_materialized_views();
"""
)
Loading
Loading