Skip to content

Commit

Permalink
Fix sat off-by-one error in output template (ordinals#4075)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Nov 14, 2024
1 parent e2b0732 commit 20c773c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3936,7 +3936,7 @@ mod tests {
</dl>
<h2>1 Sat Range</h2>
<ul class=monospace>
<li><a href=/sat/0 class=mythic>0</a>-<a href=/sat/5000000000 class=uncommon>5000000000</a> \\(5000000000 sats\\)</li>
<li><a href=/sat/0 class=mythic>0</a>-<a href=/sat/4999999999 class=common>4999999999</a> \\(5000000000 sats\\)</li>
</ul>.*"
),
);
Expand Down Expand Up @@ -3981,7 +3981,7 @@ mod tests {
</dl>
<h2>1 Sat Range</h2>
<ul class=monospace>
<li><a href=/sat/5000000000 class=uncommon>5000000000</a>-<a href=/sat/10000000000 class=uncommon>10000000000</a> \\(5000000000 sats\\)</li>
<li><a href=/sat/5000000000 class=uncommon>5000000000</a>-<a href=/sat/9999999999 class=common>9999999999</a> \\(5000000000 sats\\)</li>
</ul>.*"
),
);
Expand Down
4 changes: 2 additions & 2 deletions src/templates/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mod tests {
<h2>2 Sat Ranges</h2>
<ul class=monospace>
<li><a href=/sat/0 class=mythic>0</a></li>
<li><a href=/sat/1 class=common>1</a>-<a href=/sat/3 class=common>3</a> \\(2 sats\\)</li>
<li><a href=/sat/1 class=common>1</a>-<a href=/sat/2 class=common>2</a> \\(2 sats\\)</li>
</ul>
"
.unindent()
Expand Down Expand Up @@ -107,7 +107,7 @@ mod tests {
<h2>2 Sat Ranges</h2>
<ul class=monospace>
<li><a href=/sat/0 class=mythic>0</a></li>
<li><a href=/sat/1 class=common>1</a>-<a href=/sat/3 class=common>3</a> \\(2 sats\\)</li>
<li><a href=/sat/1 class=common>1</a>-<a href=/sat/2 class=common>2</a> \\(2 sats\\)</li>
</ul>
"
.unindent()
Expand Down
3 changes: 2 additions & 1 deletion templates/output.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ <h2>{{"Sat Range".tally(sat_ranges.len())}}</h2>
<ul class=monospace>
%% for (start, end) in sat_ranges {
%% let value = end - start;
%% let last = end - 1;
%% if value == 1 {
<li><a href=/sat/{{start}} class={{Sat(*start).rarity()}}>{{start}}</a></li>
%% } else {
<li><a href=/sat/{{start}} class={{Sat(*start).rarity()}}>{{start}}</a>-<a href=/sat/{{end}} class={{Sat(*end).rarity()}}>{{end}}</a> ({{value}} sats)</li>
<li><a href=/sat/{{start}} class={{Sat(*start).rarity()}}>{{start}}</a>-<a href=/sat/{{last}} class=common>{{last}}</a> ({{value}} sats)</li>
%% }
%% }
</ul>
Expand Down

0 comments on commit 20c773c

Please sign in to comment.