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

tstack / lnav / 18378041721-2564

09 Oct 2025 01:27PM UTC coverage: 70.133% (-0.08%) from 70.213%
18378041721-2564

push

github

tstack
[db] move lnav tables to a separate DB

Related to #1525

156 of 292 new or added lines in 11 files covered. (53.42%)

43 existing lines in 6 files now uncovered.

50274 of 71684 relevant lines covered (70.13%)

412914.39 hits per line

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

31.87
/src/progress_source.cc
1
/**
2
 * Copyright (c) 2025, Timothy Stack
3
 *
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are met:
8
 *
9
 * * Redistributions of source code must retain the above copyright notice, this
10
 * list of conditions and the following disclaimer.
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 * this list of conditions and the following disclaimer in the documentation
13
 * and/or other materials provided with the distribution.
14
 * * Neither the name of Timothy Stack nor the names of its contributors
15
 * may be used to endorse or promote products derived from this software
16
 * without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
19
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29

30
#include "progress_source.hh"
31

32
#include "base/progress.hh"
33

34
using namespace lnav::roles::literals;
35
using namespace std::chrono_literals;
36

37
bool
38
progress_source::poll()
60✔
39
{
40
    auto new_lines = std::vector<attr_line_t>();
60✔
41

42
    {
43
        auto& pt = lnav::progress_tracker::get_tasks();
60✔
44

45
        for (auto& bt : **pt.readAccess()) {
180✔
46
            auto tp = bt();
120✔
47

48
            if (tp.tp_status == lnav::progress_status_t::idle) {
120✔
49
                auto add_msgs = false;
120✔
50
                auto up_iter = this->ps_last_updates.find(tp.tp_id);
120✔
51
                if (up_iter != this->ps_last_updates.end()
120✔
52
                    && up_iter->second.lu_version == tp.tp_version)
120✔
53
                {
54
                    auto& last_update = up_iter->second;
112✔
NEW
55
                    if (std::chrono::steady_clock::now()
×
56
                        < last_update.lu_expire_time)
112✔
57
                    {
58
                        add_msgs = true;
112✔
59
                    }
60
                } else {
61
                    this->ps_last_updates[tp.tp_id] = {
8✔
62
                        tp.tp_version,
8✔
63
                        std::chrono::steady_clock::now() + 10s,
8✔
64
                    };
65
                    add_msgs = true;
8✔
66
                }
67
                if (add_msgs && !tp.tp_messages.empty()) {
120✔
NEW
68
                    auto al = attr_line_t().append(tp.tp_step);
×
NEW
69
                    new_lines.emplace_back(al);
×
NEW
70
                    auto msg_lines = std::vector<attr_line_t>();
×
NEW
71
                    for (const auto& um : tp.tp_messages) {
×
NEW
72
                        um.to_attr_line().split_lines(msg_lines);
×
73
                    }
NEW
74
                    auto last_line = msg_lines.back();
×
NEW
75
                    msg_lines.pop_back();
×
NEW
76
                    for (auto& ml : msg_lines) {
×
NEW
77
                        ml.insert(0, 2, ' ');
×
NEW
78
                        ml.al_attrs.emplace_back(line_range{0, 1},
×
NEW
79
                                                 VC_GRAPHIC.value(NCACS_VLINE));
×
NEW
80
                        new_lines.emplace_back(ml);
×
81
                    }
NEW
82
                    last_line.insert(0, 2, ' ');
×
NEW
83
                    last_line.al_attrs.emplace_back(
×
NEW
84
                        line_range{0, 1}, VC_GRAPHIC.value(NCACS_LLCORNER));
×
85

NEW
86
                    new_lines.emplace_back(last_line);
×
87
                }
88
                continue;
120✔
89
            }
120✔
90

91
            auto total_str = fmt::to_string(tp.tp_total);
×
92
            auto body = attr_line_t()
×
93
                            .appendf(FMT_STRING("{:>{}}/{} "),
×
94
                                     tp.tp_completed,
95
                                     total_str.size(),
×
96
                                     total_str)
97
                            .append(lnav::roles::keyword(tp.tp_id))
×
98
                            .append(" \u2014 ")
×
99
                            .append(tp.tp_step);
×
100
            auto lr = line_range{0, static_cast<int>(total_str.size())};
×
101
            body.al_attrs.emplace_back(lr, VC_ROLE.value(role_t::VCR_NUMBER));
×
102
            lr.lr_start = lr.lr_end + 1;
×
103
            lr.lr_end = lr.lr_start + total_str.size();
×
104
            body.al_attrs.emplace_back(lr, VC_ROLE.value(role_t::VCR_NUMBER));
×
105

106
            auto pct = (tp.tp_completed * 10) / tp.tp_total;
×
107
            auto al = attr_line_t(" \u231b [");
×
108
            if (tp.tp_completed > 0) {
×
109
                if (pct > 0 && tp.tp_completed < tp.tp_total) {
×
110
                    pct -= 1;
×
111
                }
112
                for (auto lpc = 0; lpc < pct; lpc++) {
×
113
                    al.append("\u2501"_ok);
×
114
                }
115
                if (tp.tp_completed < tp.tp_total) {
×
116
                    al.append("\u257e"_ok);
×
117
                }
118
            }
119
            al.pad_to(14).append("] ").append(body);
×
120

NEW
121
            new_lines.emplace_back(std::move(al));
×
122
        }
120✔
123
    }
124

125
    auto updated = false;
60✔
126
    if (new_lines.size() == this->ps_lines.size()) {
60✔
127
        for (size_t lpc = 0; lpc < new_lines.size(); lpc++) {
60✔
NEW
128
            if (new_lines[lpc].al_string != this->ps_lines[lpc].al_string) {
×
NEW
129
                updated = true;
×
NEW
130
                break;
×
131
            }
132
        }
133
    } else {
NEW
134
        updated = true;
×
135
    }
136
    if (updated) {
60✔
NEW
137
        this->ps_lines = std::move(new_lines);
×
138
    }
139

140
    return updated;
60✔
141
}
60✔
142

143
bool
UNCOV
144
progress_source::empty() const
×
145
{
UNCOV
146
    return this->ps_lines.empty();
×
147
}
148

149
size_t
150
progress_source::text_line_count()
1,233✔
151
{
152
    return this->ps_lines.size();
1,233✔
153
}
154

155
size_t
156
progress_source::text_line_width(textview_curses& curses)
×
157
{
158
    return text_sub_source::text_line_width(curses);
×
159
}
160

161
line_info
162
progress_source::text_value_for_line(textview_curses& tc,
×
163
                                     int line,
164
                                     std::string& value_out,
165
                                     line_flags_t flags)
166
{
167
    if (line < 0 || line >= this->ps_lines.size()) {
×
168
        return {};
×
169
    }
170

171
    value_out = this->ps_lines[line].al_string;
×
172

173
    return {};
×
174
}
175

176
size_t
177
progress_source::text_size_for_line(textview_curses& tc,
×
178
                                    int line,
179
                                    line_flags_t raw)
180
{
181
    if (line < 0 || line >= this->ps_lines.size()) {
×
182
        return 0;
×
183
    }
184

185
    return this->ps_lines[line].length();
×
186
}
187

188
void
189
progress_source::text_attrs_for_line(textview_curses& tc,
×
190
                                     int line,
191
                                     string_attrs_t& value_out)
192
{
193
    if (line < 0 || line >= this->ps_lines.size()) {
×
194
        return;
×
195
    }
196

197
    value_out = this->ps_lines[line].al_attrs;
×
198
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc