• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rero / sonar / 17425918180

03 Sep 2025 07:11AM UTC coverage: 95.796% (-0.6%) from 96.378%
17425918180

push

github

PascalRepond
translations: extract messages

Co-Authored-by: Pascal Repond <pascal.repond@rero.ch>

7816 of 8159 relevant lines covered (95.8%)

0.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.86
/sonar/modules/sitemap/tasks.py
1
# Swiss Open Access Repository
2
# Copyright (C) 2022 RERO
3
#
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU Affero General Public License as published by
6
# the Free Software Foundation, version 3 of the License.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Affero General Public License for more details.
12
#
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15

16
"""Tasks for sitemap."""
17

18
from celery import shared_task
1✔
19
from flask import current_app
1✔
20

21
from sonar.modules.organisations.api import OrganisationSearch
1✔
22
from sonar.modules.sitemap.sitemap import sitemap_generate
1✔
23

24

25
@shared_task(ignore_result=True)
1✔
26
def sitemap_generate_task():
1✔
27
    """Generate sitemap.
28

29
    Used as celery task. "ignore_result" flag means that we don't want to
30
    get the status and/or the result of the task, execution is faster.
31
    """
32
    # Generate sitemap only on production state
33
    if not current_app.config.get("SONAR_APP_PRODUCTION_STATE", False):
×
34
        return
×
35

36
    size = current_app.config.get("SONAR_APP_SITEMAP_ENTRY_SIZE", 10000)
×
37
    # Generate dedicated organisations sitemaps
38
    orgs = OrganisationSearch().get_dedicated_list()
×
39
    for org in orgs:
×
40
        if server_name := org.serverName:
×
41
            sitemap_generate(server_name, size)
×
42

43
    # Generate global sitemap
44
    sitemap_generate(current_app.config.get("SONAR_APP_DEFAULT_ORGANISATION"), size)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc