1 # SPDX-License-Identifier: GPL-2.0-only
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2022 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Contains the class which handles statistics for the
9 import of special phrases.
12 LOG = logging.getLogger()
14 class SpecialPhrasesImporterStatistics():
15 # pylint: disable-msg=too-many-instance-attributes
17 Class handling statistics of the import
18 process of special phrases.
21 self._intialize_values()
23 def _intialize_values(self):
25 Set all counts for the global
28 self.tables_created = 0
29 self.tables_deleted = 0
30 self.tables_ignored = 0
33 def notify_one_phrase_invalid(self):
35 Add +1 to the count of invalid entries
36 fetched from the wiki.
40 def notify_one_table_created(self):
42 Add +1 to the count of created tables.
44 self.tables_created += 1
46 def notify_one_table_deleted(self):
48 Add +1 to the count of deleted tables.
50 self.tables_deleted += 1
52 def notify_one_table_ignored(self):
54 Add +1 to the count of ignored tables.
56 self.tables_ignored += 1
58 def notify_import_done(self):
60 Print stats for the whole import process
63 LOG.info('====================================================================')
64 LOG.info('Final statistics of the import:')
65 LOG.info('- %s phrases were invalid.', self.invalids)
67 LOG.info(' Those invalid phrases have been skipped.')
68 LOG.info('- %s tables were ignored as they already exist on the database',
70 LOG.info('- %s tables were created', self.tables_created)
71 LOG.info('- %s tables were deleted from the database', self.tables_deleted)
72 if self.tables_deleted > 0:
73 LOG.info(' They were deleted as they are not valid anymore.')
76 LOG.warning('%s phrases were invalid and have been skipped during the whole process.',
79 self._intialize_values()