Skip to content

Commit

Permalink
Improve logging of API request
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Apr 29, 2024
1 parent 06971df commit c699ed3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lizmap/dialogs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,16 @@ def current_server_info(self, info: ServerComboData):
""" Return the current LWC server information from the server combobox. """
return self.server_combo.currentData(info)

def current_lwc_version(self) -> Optional[LwcVersions]:
def current_lwc_version(self, default_value: bool = True) -> Optional[LwcVersions]:
""" Return the current LWC version from the server combobox. """
metadata = self.current_server_info(ServerComboData.JsonMetadata.value)
# In tests, we might not have metadata in the combobox
if metadata and metadata.get('info'):
return LwcVersions.find_from_metadata(metadata)

if not default_value:
return None

if self._lwc_version:
return self._lwc_version

Expand Down
4 changes: 4 additions & 0 deletions lizmap/plausible.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def request_stat_event(self) -> bool:
# If running on CI, do not send stats
return False

if not self.dialog.current_lwc_version(default_value=False):
# Let's wait to have the JSON in the combobox
return False

current = QDateTime().currentDateTimeUtc()
if self.previous_date and self.previous_date.secsTo(current) < MIN_SECONDS:
# Not more than one request per hour
Expand Down

0 comments on commit c699ed3

Please sign in to comment.