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

qld-gov-au / ckan / ffdd3d13-9fd2-42d6-8817-f9a076d0bad6

21 Jan 2026 02:47AM UTC coverage: 79.551% (-8.3%) from 87.869%
ffdd3d13-9fd2-42d6-8817-f9a076d0bad6

Pull #239

circleci

ThrawnCA
[QOLSVC-12515] add support for specifying facet sorts via query parameters

- Use '_{facet}_sort' as a parallel to '_{facet}_limit', with comma separation for the ordering, eg
'_tags_sort=count,desc' to mimic the default popularity-based sorting.
Pull Request #239: QOLSVC-12515 alphabetical facet sort

11 of 35 new or added lines in 2 files covered. (31.43%)

13656 existing lines in 309 files now uncovered.

42766 of 53759 relevant lines covered (79.55%)

1.63 hits per line

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

100.0
/ckanext/example_flask_streaming/plugin.py
1
# encoding: utf-8
2

3
import os.path as path
2✔
4
from typing import Any
2✔
5

6
from flask import Blueprint
2✔
7
import flask
2✔
8

9
import ckan.plugins as p
2✔
10
from ckan.common import CKANConfig, streaming_response
2✔
11

12

13
def stream_string():
2✔
14
    u'''Stream may consist of any common content, like words'''
UNCOV
15
    def generate():
1✔
UNCOV
16
        for w in u'Hello World, this is served from an extension'.split():
1✔
UNCOV
17
            yield w
1✔
UNCOV
18
    return streaming_response(generate())
1✔
19

20

21
def stream_template(**kwargs: Any):
2✔
22
    u'''You can stream big templates as well.'''
23
    tpl = flask.current_app.jinja_env.get_template(u'stream.html')
1✔
24
    gen = tpl.stream(kwargs)
1✔
25
    # pass integer into `enable_buffering` to control, how many
26
    # tokens will consist in every response chunk.
27
    gen.enable_buffering()
1✔
28
    return streaming_response(gen)
1✔
29

30

31
def stream_file():
2✔
32
    u'''File stream. Just do not close it until response finished'''
33
    f_path = path.join(
1✔
34
        path.dirname(path.abspath(__file__)), u'tests/10lines.txt')
35

36
    def gen():
1✔
37
        with open(f_path) as test_file:
1✔
38
            for line in test_file:
1✔
39
                yield line
1✔
40

41
    return streaming_response(gen())
1✔
42

43

44
def stream_context():
2✔
45
    u'''Additional argument keep request context from destroying'''
46
    html = u'''{{ request.args.var }}'''
1✔
47

48
    def gen():
1✔
49
        yield flask.render_template_string(html)
1✔
50

51
    return streaming_response(gen(), with_context=True)
1✔
52

53

54
class ExampleFlaskStreamingPlugin(p.SingletonPlugin):
2✔
55
    u'''
56
    An example plugin to demonstrate Flask streaming responses.
57
    '''
58
    p.implements(p.IBlueprint)
2✔
59
    p.implements(p.IConfigurer)
2✔
60

61
    # IConfigurer
62

63
    def update_config(self, config: CKANConfig):
2✔
64
        # Add extension templates directory
65
        p.toolkit.add_template_directory(config, u'templates')
2✔
66

67
    def get_blueprint(self):
2✔
68
        u'''Return a Flask Blueprint object to be registered by the app.'''
69

70
        # Create Blueprint for plugin
71
        blueprint = Blueprint(self.name, self.__module__)
2✔
72
        blueprint.template_folder = u'templates'
2✔
73
        # Add plugin url rules to Blueprint object
74
        rules = [
2✔
75
            (u'/stream/string', u'stream_string', stream_string),
76
            (u'/stream/template/<int:count>', u'stream_template',
77
             stream_template),
78
            (u'/stream/template/', u'stream_template', stream_template),
79
            (u'/stream/file', u'stream_file', stream_file),
80
            (u'/stream/context', u'stream_context', stream_context),
81
        ]
82
        for rule in rules:
2✔
83
            blueprint.add_url_rule(*rule)
2✔
84

85
        return blueprint
2✔
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

© 2026 Coveralls, Inc