c2cgeoportal-geoportal 2.9.0.147__py3-none-any.whl → 2.9.0.150__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,7 @@
29
29
  import gettext
30
30
  import os
31
31
  import sys
32
+ import time
32
33
  from argparse import ArgumentParser, Namespace
33
34
  from collections.abc import Iterator
34
35
  from typing import TYPE_CHECKING, Any, Optional
@@ -89,6 +90,11 @@ def get_argparser() -> ArgumentParser:
89
90
  "--no-layers", action="store_false", dest="layers", help="do not import the layers (tree leaf)"
90
91
  )
91
92
  parser.add_argument("--package", help="the application package")
93
+ parser.add_argument(
94
+ "--stats",
95
+ action="store_true",
96
+ help="Print out statistics information",
97
+ )
92
98
  fill_arguments(parser)
93
99
  return parser
94
100
 
@@ -130,20 +136,8 @@ class Import:
130
136
  else:
131
137
  raise KeyError(KeyError(msg))
132
138
 
133
- # must be done only once we have loaded the project config
134
- from c2cgeoportal_commons.models.main import ( # pylint: disable=import-outside-toplevel
135
- FullTextSearch,
136
- Interface,
137
- LayerGroup,
138
- LayerWMS,
139
- LayerWMTS,
140
- Role,
141
- Theme,
142
- )
143
-
144
- self.session = session
145
- self.session.execute(FullTextSearch.__table__.delete().where(FullTextSearch.from_theme))
146
-
139
+ print("Loading translations")
140
+ start_time = time.time()
147
141
  self._: dict[str, gettext.NullTranslations] = {}
148
142
  for lang in self.languages:
149
143
  try:
@@ -155,15 +149,42 @@ class Import:
155
149
  except OSError as e:
156
150
  self._[lang] = gettext.NullTranslations()
157
151
  print(f"Warning: {e} (language: {lang})")
152
+ if self.options.stats:
153
+ print(
154
+ f"Translations loaded in {time.time() - start_time:.2f} seconds "
155
+ f"({len(self.languages)} languages)"
156
+ )
158
157
 
159
- query = self.session.query(Interface)
160
- if options.interfaces is not None:
161
- query = query.filter(Interface.name.in_(options.interfaces))
162
- else:
163
- query = query.filter(Interface.name.notin_(options.exclude_interfaces))
164
- self.interfaces = query.all()
158
+ print("Loading the database")
159
+ # Must be done only once we have loaded the project config
160
+ from c2cgeoportal_commons.models.main import ( # pylint: disable=import-outside-toplevel
161
+ FullTextSearch,
162
+ Interface,
163
+ LayerGroup,
164
+ LayerWMS,
165
+ LayerWMTS,
166
+ Role,
167
+ Theme,
168
+ )
169
+
170
+ self.session = session
171
+ if self.options.stats:
172
+ print(
173
+ f"Session loaded in {time.time() - start_time:.2f} seconds "
174
+ f"({len(self.languages)} languages)"
175
+ )
176
+
177
+ print("Delete the full-text search table")
178
+ start_time = time.time()
179
+ self.session.execute(FullTextSearch.__table__.delete().where(FullTextSearch.from_theme))
180
+ if self.options.stats:
181
+ print(
182
+ f"Deleted old entries in the full-text search table in "
183
+ f"{time.time() - start_time:.2f} seconds"
184
+ )
165
185
 
166
186
  print("Create cache")
187
+ start_time = time.time()
167
188
  self._layerswms_cache = (
168
189
  self.session.query(LayerWMS).options(sqlalchemy.orm.subqueryload(LayerWMS.metadatas)).all()
169
190
  )
@@ -186,8 +207,28 @@ class Import:
186
207
  )
187
208
  .all()
188
209
  )
210
+ if self.options.stats:
211
+ print(
212
+ f"Cache created in {time.time() - start_time:.2f} seconds "
213
+ f"({len(self._layerswms_cache)} layerswms, "
214
+ f"{len(self._layerswmts_cache)} layerswmts, "
215
+ f"{len(self._layergroup_cache)} layergroups, "
216
+ f"{len(all_themes)} themes)"
217
+ )
218
+
219
+ print("Loading interfaces")
220
+ start_time = time.time()
221
+ query = self.session.query(Interface)
222
+ if options.interfaces is not None:
223
+ query = query.filter(Interface.name.in_(options.interfaces))
224
+ else:
225
+ query = query.filter(Interface.name.notin_(options.exclude_interfaces))
226
+ self.interfaces = query.all()
227
+ if self.options.stats:
228
+ print(f"Loaded {len(self.interfaces)} interfaces in " f"{time.time() - start_time:.2f} seconds")
189
229
 
190
230
  print("Collecting data")
231
+ start_time = time.time()
191
232
 
192
233
  self.public_theme: dict[int, list[int]] = {}
193
234
  self.public_group: dict[int, list[int]] = {}
@@ -204,7 +245,14 @@ class Import:
204
245
  for theme in all_themes:
205
246
  self._add_theme(theme, role)
206
247
 
248
+ if self.options.stats:
249
+ print(
250
+ f"Collected {len(self.full_text_search)} entries in "
251
+ f"{time.time() - start_time:.2f} seconds"
252
+ )
253
+
207
254
  print(f"Starting to fill the full-text search table with {len(self.full_text_search)} entries")
255
+ start_time = time.time()
208
256
  self.session.execute(
209
257
  sqlalchemy.insert(FullTextSearch).values(
210
258
  {
@@ -220,6 +268,12 @@ class Import:
220
268
  ),
221
269
  self.full_text_search,
222
270
  )
271
+ if self.options.stats:
272
+ print(
273
+ f"Filled the full-text search table in "
274
+ f"{time.time() - start_time:.2f} seconds "
275
+ f"({len(self.full_text_search)} entries)"
276
+ )
223
277
 
224
278
  def _add_fts(
225
279
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: c2cgeoportal-geoportal
3
- Version: 2.9.0.147
3
+ Version: 2.9.0.150
4
4
  Summary: c2cgeoportal geoportal
5
5
  Home-page: https://github.com/camptocamp/c2cgeoportal/
6
6
  Author: Camptocamp
@@ -147,7 +147,7 @@ c2cgeoportal_geoportal/scripts/c2cupgrade.py,sha256=oWgl5ngJaUVXDKJqJ33aZB8ET_Xc
147
147
  c2cgeoportal_geoportal/scripts/create_demo_theme.py,sha256=-SL-fvAPjgiJZEKYcbhXsZm713txhtWQB18X231k6xQ,3263
148
148
  c2cgeoportal_geoportal/scripts/manage_users.py,sha256=Ih3X_V_xUw59Ums4a1x6qQQtz9VtE7PaxAj-tiZIOPg,5586
149
149
  c2cgeoportal_geoportal/scripts/pcreate.py,sha256=xU87K_JYwFE6U4zEGjHvqNj2iiSuAhPkfWMpI576mZ8,11245
150
- c2cgeoportal_geoportal/scripts/theme2fts.py,sha256=6JqfRO5mjuimMOMjdMCpK9whSaR4DT8UdEJEp7ob2zE,15584
150
+ c2cgeoportal_geoportal/scripts/theme2fts.py,sha256=tVEeqf1l_PaTw3qpNX2ZvJHu4JO6IgY6upir24HPxJM,17616
151
151
  c2cgeoportal_geoportal/scripts/urllogin.py,sha256=qGOOvx2ZN3qnENGzo8NScRqfFC06l1yc48vU6Qx3MBo,3319
152
152
  c2cgeoportal_geoportal/templates/login.html,sha256=Jy8CUw2KrSviePknsvWJLDqCUXam-vPhnMUv7UcD4Pc,2475
153
153
  c2cgeoportal_geoportal/templates/notlogin.html,sha256=XLCwJ8q7hqk6GIaxwhyMOaMZZZvsD_MMZaCERO8n2AY,1528
@@ -187,8 +187,8 @@ tests/test_mapserverproxy_route_predicate.py,sha256=SzILSSzIuilzIkUYVPZiVzLwW1du
187
187
  tests/test_raster.py,sha256=82NJ2MXgZlMqs0ytN-VgNw376iURdk4PkAg__dyh5ns,11948
188
188
  tests/test_wmstparsing.py,sha256=xjA8nJuXFl3H5Bfs4sJw_8qX8E8qvAALK7Hs2-DTP2A,9054
189
189
  tests/xmlstr.py,sha256=rkTKSU4FGjupBKLx75H8o-goB0KbQrxDvdpc6xVX_uQ,5985
190
- c2cgeoportal_geoportal-2.9.0.147.dist-info/METADATA,sha256=YNcOXV1RXATyE4ZB-mR5edhnxllGfMw-4Rv01hFyfvw,1923
191
- c2cgeoportal_geoportal-2.9.0.147.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
192
- c2cgeoportal_geoportal-2.9.0.147.dist-info/entry_points.txt,sha256=3dnX260FsLX_AubeNMdyeta_z1X4CxcD3steAlfPx2I,1414
193
- c2cgeoportal_geoportal-2.9.0.147.dist-info/top_level.txt,sha256=PJIbY7Nx51dDrJ052f5mDA7c6Tehm5aD-Gb32L_CtJA,29
194
- c2cgeoportal_geoportal-2.9.0.147.dist-info/RECORD,,
190
+ c2cgeoportal_geoportal-2.9.0.150.dist-info/METADATA,sha256=7oUFqenYAbtCl1Ahdks-xjb3VtPQ0eQEoq9ufFXGf7g,1923
191
+ c2cgeoportal_geoportal-2.9.0.150.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
192
+ c2cgeoportal_geoportal-2.9.0.150.dist-info/entry_points.txt,sha256=3dnX260FsLX_AubeNMdyeta_z1X4CxcD3steAlfPx2I,1414
193
+ c2cgeoportal_geoportal-2.9.0.150.dist-info/top_level.txt,sha256=PJIbY7Nx51dDrJ052f5mDA7c6Tehm5aD-Gb32L_CtJA,29
194
+ c2cgeoportal_geoportal-2.9.0.150.dist-info/RECORD,,