Skip to content

Commit 772c78b

Browse files
authored
Merge pull request #8 from AOSC-Dev/remove-qa-feature
feat: remove qa feature
2 parents 0df2769 + 661895b commit 772c78b

File tree

12 files changed

+1
-1162
lines changed

12 files changed

+1
-1162
lines changed

src/filters.rs

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use crate::utils::{issue_code, ver_rel};
2-
use itertools::Itertools;
3-
use serde_json::Value;
1+
use crate::utils::ver_rel;
42
use std::fmt::Display;
53

64
macro_rules! bail {
@@ -58,10 +56,6 @@ pub fn strftime_i32(timestamp: &i32, s: &str) -> ::askama::Result<String> {
5856
}
5957
}
6058

61-
pub fn calc_color_ratio(ratio: &f64, max: &f64) -> ::askama::Result<f64> {
62-
Ok(100.0 - 100.0 / 3.0 * (*ratio) / (*max))
63-
}
64-
6559
pub fn sizeof_fmt(size: &i64) -> ::askama::Result<String> {
6660
let size = size::Size::from_bytes(*size);
6761
Ok(size.to_string())
@@ -80,10 +74,6 @@ pub fn fmt_pkg_status(status: &i32) -> ::askama::Result<&'static str> {
8074
})
8175
}
8276

83-
pub fn fmt_issue_code(code: &i32) -> ::askama::Result<&'static str> {
84-
Ok(issue_code(*code).unwrap_or("unknown"))
85-
}
86-
8777
pub fn sizeof_fmt_ls(num: &i64) -> ::askama::Result<String> {
8878
if num.abs() < 1024 {
8979
return Ok(num.to_string());
@@ -123,76 +113,10 @@ pub fn ls_perm(perm: &i32, ftype: &i16) -> ::askama::Result<String> {
123113
Ok(format!("{ftype}{perm}"))
124114
}
125115

126-
pub fn ls_perm_str(perm: &i32, ftype: &str) -> ::askama::Result<String> {
127-
let ftype = match ftype {
128-
"lnk" => 'l',
129-
"sock" => 's',
130-
"chr" => 'c',
131-
"blk" => 'b',
132-
"dir" => 'd',
133-
"fifo" => 'p',
134-
_ => '-',
135-
};
136-
137-
let perm: String = format!("{perm:b}")
138-
.chars()
139-
.zip("rwxrwxrwx".chars())
140-
.map(|(a, b)| if a == '1' { b } else { '-' })
141-
.collect();
142-
143-
Ok(format!("{ftype}{perm}"))
144-
}
145-
146116
pub fn fmt_default<T: Display + Default>(x: &Option<T>) -> ::askama::Result<String> {
147117
if let Some(x) = x {
148118
Ok(format!("{x}"))
149119
} else {
150120
Ok(format!("{}", T::default()))
151121
}
152122
}
153-
154-
/// get json value and convert it to string
155-
pub fn value_string(json: &Value, key: &str) -> ::askama::Result<String> {
156-
Ok(json
157-
.get(key)
158-
.map(|v| v.as_str().map(|s| s.to_string()).unwrap_or_default())
159-
.unwrap_or_default())
160-
}
161-
162-
pub fn value_array_string(json: &Value, key: &str) -> ::askama::Result<Vec<String>> {
163-
Ok(json
164-
.get(key)
165-
.map(|v| {
166-
v.as_array()
167-
.map(|v| {
168-
v.iter()
169-
.map(|v| v.as_str().unwrap_or_default().to_string())
170-
.collect_vec()
171-
})
172-
.unwrap_or_default()
173-
})
174-
.unwrap_or_default())
175-
}
176-
177-
pub fn len<T>(v: &Vec<T>) -> ::askama::Result<usize> {
178-
Ok(v.len())
179-
}
180-
pub fn value_array<'a>(json: &'a Value, key: &'a str) -> ::askama::Result<&'a Vec<serde_json::Value>> {
181-
if let Some(v) = json.get(key) {
182-
if let Some(v) = v.as_array() {
183-
Ok(v)
184-
} else {
185-
bail!("value `{v:?}` is not array type")
186-
}
187-
} else {
188-
bail!("no such key `{key}` in {json:?}")
189-
}
190-
}
191-
192-
pub fn value_i64(json: &Value, key: &str) -> ::askama::Result<i64> {
193-
Ok(json.get(key).map(|v| v.as_i64().unwrap_or(0)).unwrap_or(0))
194-
}
195-
196-
pub fn value_i32(json: &Value, key: &str) -> ::askama::Result<i32> {
197-
Ok(json.get(key).map(|v| v.as_i64().unwrap_or(0) as i32).unwrap_or(0))
198-
}

src/main.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ async fn main() -> Result<()> {
8686
.typed_get(repo)
8787
.typed_get(packages)
8888
.typed_get(files)
89-
.typed_get(qa)
90-
.typed_get(qa_index)
91-
.typed_get(qa_code)
92-
.typed_get(qa_repo)
93-
.typed_get(qa_package)
9489
.typed_get(cleanmirror)
9590
.typed_get(revdep)
9691
.typed_get(license)

src/sql.rs

Lines changed: 0 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -595,163 +595,6 @@ ORDER BY
595595
ver
596596
";
597597

598-
pub const SQL_ISSUES_STATS: &str = "
599-
SELECT
600-
q1.repo,
601-
q1.errno,
602-
q1.cnt,
603-
round(
604-
(q1.cnt :: float8 / coalesce(q2.total, s.cnt)) :: numeric,
605-
5
606-
) :: float8 ratio
607-
FROM
608-
(
609-
SELECT
610-
repo,
611-
errno,
612-
count(DISTINCT package) cnt
613-
FROM
614-
pv_package_issues
615-
GROUP BY
616-
GROUPING SETS ((repo, errno), ())
617-
) q1
618-
LEFT JOIN (
619-
SELECT
620-
repo,
621-
count(package) cnt
622-
FROM
623-
v_packages_new
624-
GROUP BY
625-
repo
626-
) s ON s.repo = q1.repo
627-
LEFT JOIN (
628-
SELECT
629-
b.name repo,
630-
count(DISTINCT p.name) total
631-
FROM
632-
package_versions v
633-
INNER JOIN packages p ON v.package = p.name
634-
INNER JOIN tree_branches b ON b.tree = p.tree
635-
AND b.branch = v.branch
636-
GROUP BY
637-
GROUPING SETS ((b.name), ())
638-
) q2 ON q2.repo IS NOT DISTINCT
639-
FROM
640-
q1.repo
641-
";
642-
643-
pub const SQL_ISSUES_RECENT: &str = "
644-
SELECT
645-
package,
646-
version,
647-
array_agg(
648-
DISTINCT errno
649-
ORDER BY
650-
errno
651-
) errs
652-
FROM
653-
pv_package_issues
654-
WHERE
655-
errno != 311
656-
GROUP BY
657-
package,
658-
version
659-
ORDER BY
660-
max(mtime) DESC
661-
LIMIT
662-
10
663-
";
664-
665-
pub const SQL_ISSUES_CODE: &str = r#"
666-
SELECT
667-
package "name",
668-
array_agg(DISTINCT "version") versions,
669-
array_agg(DISTINCT branch) branches,
670-
(array_agg(filename)) [1] filename,
671-
max(filecount) filecount
672-
FROM
673-
(
674-
SELECT
675-
package,
676-
"version",
677-
substring(
678-
repo
679-
from
680-
position('/' in repo) + 1
681-
) branch,
682-
max("level") "level",
683-
(array_agg(filename)) [1] filename,
684-
count(filename) filecount
685-
FROM
686-
pv_package_issues
687-
WHERE
688-
errno = $1
689-
AND coalesce(repo = $2, TRUE)
690-
GROUP BY
691-
package,
692-
version,
693-
repo
694-
) q1
695-
GROUP BY
696-
package
697-
ORDER BY
698-
package
699-
"#;
700-
701-
pub const SQL_ISSUES_PACKAGE: &str = "
702-
SELECT
703-
errno,
704-
version,
705-
repo,
706-
filecount,
707-
level,
708-
filename,
709-
detail
710-
FROM
711-
(
712-
SELECT
713-
errno,
714-
version,
715-
repo,
716-
level,
717-
filename,
718-
detail,
719-
max(rowid) OVER (PARTITION BY errno, version, repo) filecount,
720-
rowid
721-
FROM
722-
(
723-
SELECT
724-
errno,
725-
version,
726-
repo,
727-
level,
728-
filename,
729-
detail,
730-
count(*) OVER (PARTITION BY errno, version, repo) filecount,
731-
row_number() OVER (
732-
PARTITION BY errno,
733-
version,
734-
repo
735-
ORDER BY
736-
level,
737-
filename
738-
) rowid
739-
FROM
740-
pv_package_issues
741-
WHERE
742-
package = $1
743-
) q1
744-
) q2
745-
WHERE
746-
rowid <= 500
747-
ORDER BY
748-
errno,
749-
version DESC,
750-
repo,
751-
level,
752-
filename
753-
";
754-
755598
pub const SQL_GET_DEB_LIST_HASARCH: &str = "
756599
SELECT
757600
dp.filename,

src/utils.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -142,44 +142,6 @@ pub async fn fallback(uri: Uri) -> impl IntoResponse {
142142
crate::utils::Error::NotFound(format!("No route for {}", uri))
143143
}
144144

145-
pub fn issue_code(code: i32) -> Option<&'static str> {
146-
match code {
147-
100 => Some("Metadata"),
148-
101 => Some("Syntax error(s) in spec"),
149-
102 => Some("Syntax error(s) in defines"),
150-
103 => Some("Package name is not valid"),
151-
111 => Some("Package may be out-dated"),
152-
112 => Some("SRCTBL uses HTTP"),
153-
121 => Some("The last commit message was badly formatted"),
154-
122 => Some("Multiple packages changed in the last commit"),
155-
123 => Some("Force-pushed recently (last N commit - TBD)"),
156-
200 => Some("Build Process"),
157-
201 => Some("Failed to get source"),
158-
202 => Some("Failed to get dependencies"),
159-
211 => Some("Failed to build from source (FTBFS)"),
160-
221 => Some("Failed to launch packaged executable(s)"),
161-
222 => Some("Feature(s) non-functional, or unit test(s) failed"),
162-
300 => Some("Payload (.deb Package)"),
163-
301 => Some("Bad or corrupted .deb file"),
164-
302 => Some(".deb file too small"),
165-
303 => Some("Bad .deb filename or storage path"),
166-
311 => Some("Bad .deb Maintainer metadata"),
167-
321 => Some("File(s) stored in unexpected path(s) in .deb"),
168-
322 => Some("Zero-byte file(s) found in .deb"),
169-
323 => Some("File(s) with bad owner/group found in .deb"),
170-
324 => Some("File(s) with bad permission found in .deb"),
171-
400 => Some("Dependencies"),
172-
401 => Some("BUILDDEP unmet"),
173-
402 => Some("Duplicate package in tree"),
174-
411 => Some("PKGDEP unmet"),
175-
412 => Some("Duplicate package in repository"),
176-
421 => Some("File collision(s)"),
177-
431 => Some("Library version (sover) dependency unmet"),
178-
432 => Some("Library dependency without PKGDEP"),
179-
_ => None,
180-
}
181-
}
182-
183145
pub type Query = QueryExtractor;
184146

185147
#[derive(Deserialize, Debug, Clone, Default)]
@@ -448,19 +410,6 @@ impl std::fmt::Display for SrcType {
448410
}
449411
}
450412

451-
macro_rules! skip_none {
452-
($res:expr) => {
453-
match $res {
454-
Some(val) => val,
455-
None => {
456-
tracing::debug!("skip none");
457-
continue;
458-
}
459-
}
460-
};
461-
}
462-
pub(crate) use skip_none;
463-
464413
pub const REPO_CAT: [(&str, &str); 3] = [("base", ""), ("bsp", "BSP"), ("overlay", "Overlay")];
465414
const DEP_REL: [(&str, &str); 8] = [
466415
("PKGDEP", "Depends"),

src/views/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
mod index;
22
mod misc;
33
mod package;
4-
mod qa;
54
mod repo;
65
mod search;
76

87
pub use index::{index, license, updates};
98
pub use misc::{cleanmirror, pkglist, pkgtrie, static_files};
109
pub use package::{changelog, files, packages, revdep};
11-
pub use qa::{qa, qa_code, qa_index, qa_package, qa_repo};
1210
pub use repo::{ghost, lagging, missing, repo};
1311
pub use search::search;

0 commit comments

Comments
 (0)