Sort and count refs
This commit is contained in:
parent
72f762464d
commit
520ee0f7da
3 changed files with 22 additions and 13 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"db_name": "SQLite",
|
"db_name": "SQLite",
|
||||||
"query": "SELECT name, hash, tracked, message FROM refs JOIN commits USING (hash) ",
|
"query": "SELECT name, hash, tracked, message FROM refs JOIN commits USING (hash) ORDER BY name ASC ",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
|
|
@ -34,5 +34,5 @@
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "1e09e422a6fd826b7dfdaf52a271e77672c4dbc933af42a59fd8a8459e495732"
|
"hash": "39e21f75c4f68be1e4f64c4a9c0a38974f12556b6ac463f21f7729f758dec886"
|
||||||
}
|
}
|
||||||
|
|
@ -8,8 +8,8 @@ use crate::{config::Config, db, somehow};
|
||||||
struct Ref {
|
struct Ref {
|
||||||
name: String,
|
name: String,
|
||||||
hash: String,
|
hash: String,
|
||||||
tracked: bool,
|
|
||||||
short: String,
|
short: String,
|
||||||
|
tracked: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
|
|
@ -18,7 +18,8 @@ struct IndexTemplate {
|
||||||
base: String,
|
base: String,
|
||||||
repo_name: String,
|
repo_name: String,
|
||||||
current: String,
|
current: String,
|
||||||
refs: Vec<Ref>,
|
tracked_refs: Vec<Ref>,
|
||||||
|
untracked_refs: Vec<Ref>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get(
|
pub async fn get(
|
||||||
|
|
@ -29,6 +30,7 @@ pub async fn get(
|
||||||
"\
|
"\
|
||||||
SELECT name, hash, tracked, message FROM refs \
|
SELECT name, hash, tracked, message FROM refs \
|
||||||
JOIN commits USING (hash) \
|
JOIN commits USING (hash) \
|
||||||
|
ORDER BY name ASC \
|
||||||
"
|
"
|
||||||
)
|
)
|
||||||
.fetch(&db)
|
.fetch(&db)
|
||||||
|
|
@ -41,10 +43,21 @@ pub async fn get(
|
||||||
.try_collect::<Vec<_>>()
|
.try_collect::<Vec<_>>()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
let mut tracked_refs = vec![];
|
||||||
|
let mut untracked_refs = vec![];
|
||||||
|
for reference in refs {
|
||||||
|
if reference.tracked {
|
||||||
|
tracked_refs.push(reference);
|
||||||
|
} else {
|
||||||
|
untracked_refs.push(reference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(IndexTemplate {
|
Ok(IndexTemplate {
|
||||||
base: config.web.base(),
|
base: config.web.base(),
|
||||||
repo_name: config.repo.name(),
|
repo_name: config.repo.name(),
|
||||||
current: "index".to_string(),
|
current: "index".to_string(),
|
||||||
refs,
|
tracked_refs,
|
||||||
|
untracked_refs,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,24 +5,20 @@
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h2>Refs</h2>
|
<h2>Refs</h2>
|
||||||
<details>
|
<details>
|
||||||
<summary>Tracked</summary>
|
<summary>Tracked ({{ tracked_refs.len() }})</summary>
|
||||||
<dl>
|
<dl>
|
||||||
{% for ref in refs %}
|
{% for ref in tracked_refs %}
|
||||||
{% if ref.tracked %}
|
|
||||||
<dt>{{ ref.name }}</dt>
|
<dt>{{ ref.name }}</dt>
|
||||||
<dd><a href="{{ base }}/commit/{{ ref.hash }}">{{ ref.short }}</a></dd>
|
<dd><a href="{{ base }}/commit/{{ ref.hash }}">{{ ref.short }}</a></dd>
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</dl>
|
</dl>
|
||||||
</details>
|
</details>
|
||||||
<details>
|
<details>
|
||||||
<summary>Untracked</summary>
|
<summary>Untracked ({{ untracked_refs.len() }})</summary>
|
||||||
<dl>
|
<dl>
|
||||||
{% for ref in refs %}
|
{% for ref in untracked_refs %}
|
||||||
{% if !ref.tracked %}
|
|
||||||
<dt>{{ ref.name }}</dt>
|
<dt>{{ ref.name }}</dt>
|
||||||
<dd><a href="{{ base }}/commit/{{ ref.hash }}">{{ ref.short }}</a></dd>
|
<dd><a href="{{ base }}/commit/{{ ref.hash }}">{{ ref.short }}</a></dd>
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</dl>
|
</dl>
|
||||||
</details>
|
</details>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue