Skip to content
This repository was archived by the owner on Mar 25, 2022. It is now read-only.

Commit f68df77

Browse files
authored
Merge pull request #15 from TeamPractical/niklas
- Hide some users from leaderboard
2 parents a89ce76 + 907feb0 commit f68df77

File tree

6 files changed

+10
-3
lines changed

6 files changed

+10
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/target
22
/log
3-
.env
3+
.env
4+
hidden_users.txt

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "smartbeans-backend"
3-
version = "1.2.1"
3+
version = "1.3.0"
44
authors = ["Niklas Birth <[email protected]>"]
55
edition = "2018"
66
default-run = "backend"

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ fn main() {
99
let git_hash = String::from_utf8(output.stdout).unwrap();
1010

1111
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
12+
13+
std::fs::File::create("hidden_users.txt").unwrap();
1214
}

src/routes/misc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ pub fn leaderboard(user: guards::User) -> Json<Value> {
4848
.load::<(String, i64)>(&crate::database::establish_connection())
4949
.expect("Database error")
5050
.into_iter()
51+
.filter(|(user, _)| {
52+
!crate::static_data::HIDDEN_USERS.contains(&&user[..])
53+
})
5154
.map(|(user, score)| {
5255
use crate::schema::charnames::dsl::*;
5356

src/static_data.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ lazy_static! {
2121
};
2222

2323
pub static ref NAMES: Vec<&'static str> = include_str!("../data/names.txt").split('\n').collect();
24+
pub static ref HIDDEN_USERS: Vec<&'static str> = include_str!("../hidden_users.txt").split('\n').collect();
2425
}

0 commit comments

Comments
 (0)