Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ zip = { version = "6.0.0", default-features = false, features = [
zxcvbn = "3.1.0"

[workspace.lints.clippy]
result_large_err = "allow"
bool_to_int_with_if = "warn"
borrow_as_ptr = "warn"
cfg_not_test = "warn"
Expand Down
2 changes: 1 addition & 1 deletion apps/daedalus_client/src/minecraft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub async fn fetch(semaphore: Arc<Semaphore>) -> Result<FetchResult, Error> {
.chain(existing_versions.into_iter())
.collect::<Vec<_>>();

new_versions.sort_by(|a, b| b.release_time.cmp(&a.release_time));
new_versions.sort_by_key(|b| std::cmp::Reverse(b.release_time));

// create and upload the new manifest
let version_manifest_path = format!(
Expand Down
4 changes: 2 additions & 2 deletions apps/labrinth/src/database/models/project_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ impl DBProject {
} = loaders_ptypes_games.remove(&project_id).map(|x|x.1).unwrap_or_default();
// Each version is a tuple of (DBVersionId, DateTime<Utc>)
let mut versions = versions.remove(&project_id).map(|x| x.1).unwrap_or_default();
versions.sort_by(|a, b| a.1.cmp(&b.1));
versions.sort_by_key(|a| a.1);
let mut gallery = mods_gallery.remove(&project_id).map(|x| x.1).unwrap_or_default();
let urls = links.remove(&project_id).map(|x| x.1).unwrap_or_default();
let version_fields = version_fields.remove(&project_id).map(|x| x.1).unwrap_or_default();
Expand Down Expand Up @@ -925,7 +925,7 @@ impl DBProject {
games,
versions: versions.into_iter().map(|x| x.0).collect(),
gallery_items: {
gallery.sort_by(|a, b| a.ordering.cmp(&b.ordering));
gallery.sort_by_key(|a| a.ordering);
gallery
},
urls,
Expand Down
2 changes: 1 addition & 1 deletion apps/labrinth/src/database/models/thread_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl DBThread {
)
.ok()
.unwrap_or_default();
messages.sort_by(|a, b| a.created.cmp(&b.created));
messages.sort_by_key(|a| a.created);
messages
},
members: x.members.unwrap_or_default().into_iter().map(DBUserId).collect(),
Expand Down
2 changes: 2 additions & 0 deletions apps/labrinth/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![recursion_limit = "256"]

use actix_web::dev::Service;
use actix_web::middleware::from_fn;
use actix_web::{App, HttpServer};
Expand Down
2 changes: 1 addition & 1 deletion apps/labrinth/src/queue/payouts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ async fn get_tremendous_payout_methods(
.into_iter()
.map(|x| PayoutDecimal(x.min))
.collect::<Vec<_>>();
values.sort_by(|a, b| a.0.cmp(&b.0));
values.sort_by_key(|a| a.0);

PayoutInterval::Fixed { values }
} else if let Some(first) = product.skus.first() {
Expand Down
2 changes: 1 addition & 1 deletion apps/labrinth/src/routes/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub async fn forge_updates(
)
.await?;

versions.sort_by(|a, b| b.date_published.cmp(&a.date_published));
versions.sort_by_key(|b| std::cmp::Reverse(b.date_published));

#[derive(Serialize)]
struct ForgeUpdates {
Expand Down
4 changes: 2 additions & 2 deletions apps/labrinth/src/routes/v3/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,10 +1359,10 @@ pub async fn dependency_list_internal(
)
.await?;

projects.sort_by(|a, b| b.published.cmp(&a.published));
projects.sort_by_key(|b| std::cmp::Reverse(b.published));
projects.dedup_by(|a, b| a.id == b.id);

versions.sort_by(|a, b| b.date_published.cmp(&a.date_published));
versions.sort_by_key(|b| std::cmp::Reverse(b.date_published));
versions.dedup_by(|a, b| a.id == b.id);

Ok(HttpResponse::Ok().json(DependencyInfo { projects, versions }))
Expand Down
2 changes: 1 addition & 1 deletion apps/labrinth/src/routes/v3/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub async fn loader_list(
})
.collect::<Vec<_>>();

results.sort_by(|a, b| a.name.to_lowercase().cmp(&b.name.to_lowercase()));
results.sort_by_key(|a| a.name.to_lowercase());

Ok(HttpResponse::Ok().json(results))
}
Expand Down
2 changes: 1 addition & 1 deletion apps/labrinth/src/routes/v3/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ pub async fn user_notifications(
.map(Into::into)
.collect();

notifications.sort_by(|a, b| b.created.cmp(&a.created));
notifications.sort_by_key(|b| std::cmp::Reverse(b.created));
Ok(HttpResponse::Ok().json(notifications))
} else {
Err(ApiError::NotFound)
Expand Down
9 changes: 2 additions & 7 deletions apps/labrinth/src/search/backend/typesense/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ pub enum Bucketing {
BucketSize(u64),
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(rename_all = "snake_case")]
pub enum TextMatchType {
MaxScore,
#[default]
MaxWeight,
SumScore,
}
Expand All @@ -59,12 +60,6 @@ impl TextMatchType {
}
}

impl Default for TextMatchType {
fn default() -> Self {
Self::MaxWeight
}
}

impl Default for Bucketing {
fn default() -> Self {
Self::Buckets(5)
Expand Down
4 changes: 2 additions & 2 deletions apps/labrinth/src/search/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ async fn index_versions(
}

let all_version_ids = versions
.iter()
.flat_map(|(_, version_ids)| version_ids.iter())
.values()
.flat_map(|version_ids| version_ids.iter())
.map(|(version_id, _)| version_id.0)
.collect::<Vec<i64>>();

Expand Down
4 changes: 2 additions & 2 deletions apps/labrinth/src/util/webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,10 @@ fn get_gv_range(
mut all_game_versions: Vec<MinecraftGameVersion>,
) -> Vec<String> {
// both -> least to greatest
game_versions.sort_by(|a, b| a.created.cmp(&b.created));
game_versions.sort_by_key(|a| a.created);
game_versions.dedup_by(|a, b| a.version == b.version);

all_game_versions.sort_by(|a, b| a.created.cmp(&b.created));
all_game_versions.sort_by_key(|a| a.created);

let all_releases = all_game_versions
.iter()
Expand Down
161 changes: 0 additions & 161 deletions docker-compose.yml
Comment thread
fetchfern marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -51,167 +51,6 @@ services:
interval: 3s
timeout: 5s
retries: 3
elasticsearch-certs:
image: elasticsearch:9.3.0
container_name: labrinth-elasticsearch-certs
user: '0'
networks:
- elasticsearch-mesh
restart: 'no'
volumes:
- elasticsearch-certs:/usr/share/elasticsearch/config/certs
command: |
bash -c '
set -euo pipefail
if [ ! -s config/certs/ca/ca.crt ] || [ ! -s config/certs/elasticsearch0/elasticsearch0.crt ] || [ ! -s config/certs/elasticsearch1/elasticsearch1.crt ] || [ ! -s config/certs/elasticsearch2/elasticsearch2.crt ]; then
rm -rf config/certs/*
printf "%s\n" \
"instances:" \
" - name: elasticsearch0" \
" dns:" \
" - elasticsearch0" \
" - localhost" \
" ip:" \
" - 127.0.0.1" \
" - name: elasticsearch1" \
" dns:" \
" - elasticsearch1" \
" - localhost" \
" ip:" \
" - 127.0.0.1" \
" - name: elasticsearch2" \
" dns:" \
" - elasticsearch2" \
" - localhost" \
" ip:" \
" - 127.0.0.1" \
> config/certs/instances.yml
bin/elasticsearch-certutil ca --silent --pem --out config/certs/ca.zip
unzip config/certs/ca.zip -d config/certs
bin/elasticsearch-certutil cert --silent --pem --in config/certs/instances.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key --out config/certs/certs.zip
unzip config/certs/certs.zip -d config/certs
fi
chown -R 1000:0 config/certs
find config/certs -type d -exec chmod 750 {} \;
find config/certs -type f -exec chmod 640 {} \;
echo "Set up certificates"
'
elasticsearch0:
image: elasticsearch:9.3.0
container_name: labrinth-elasticsearch0
networks:
- elasticsearch-mesh
restart: on-failure
depends_on:
elasticsearch-certs:
condition: service_completed_successfully
ports:
- '127.0.0.1:9200:9200'
volumes:
- elasticsearch0-data:/usr/share/elasticsearch/data
- elasticsearch-certs:/usr/share/elasticsearch/config/certs:ro
environment:
- logger.level=WARN
- node.name=elasticsearch0
- cluster.name=labrinth
- cluster.initial_master_nodes=elasticsearch0,elasticsearch1,elasticsearch2
- discovery.seed_hosts=elasticsearch1,elasticsearch2
- bootstrap.memory_lock=false
# auth
- xpack.security.enabled=true
- xpack.security.transport.ssl.enabled=true
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.security.transport.ssl.key=certs/elasticsearch0/elasticsearch0.key
- xpack.security.transport.ssl.certificate=certs/elasticsearch0/elasticsearch0.crt
- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
- ELASTIC_USERNAME=elastic
- ELASTIC_PASSWORD=elastic
mem_limit: 1g
healthcheck:
test:
[
'CMD-SHELL',
'curl -s -u elastic:elastic http://localhost:9200/_cluster/health | grep -qE "\"status\":\"(yellow|green)\""',
]
interval: 10s
timeout: 5s
retries: 10
elasticsearch1:
image: elasticsearch:9.3.0
container_name: labrinth-elasticsearch1
networks:
- elasticsearch-mesh
restart: on-failure
depends_on:
elasticsearch-certs:
condition: service_completed_successfully
volumes:
- elasticsearch1-data:/usr/share/elasticsearch/data
- elasticsearch-certs:/usr/share/elasticsearch/config/certs:ro
environment:
- logger.level=WARN
- node.name=elasticsearch1
- cluster.name=labrinth
- cluster.initial_master_nodes=elasticsearch0,elasticsearch1,elasticsearch2
- discovery.seed_hosts=elasticsearch0,elasticsearch2
- bootstrap.memory_lock=false
# auth
- xpack.security.enabled=true
- xpack.security.transport.ssl.enabled=true
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.security.transport.ssl.key=certs/elasticsearch1/elasticsearch1.key
- xpack.security.transport.ssl.certificate=certs/elasticsearch1/elasticsearch1.crt
- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
- ELASTIC_USERNAME=elastic
- ELASTIC_PASSWORD=elastic
mem_limit: 1g
healthcheck:
test:
[
'CMD-SHELL',
'curl -s -u elastic:elastic http://localhost:9200/_cluster/health | grep -qE "\"status\":\"(yellow|green)\""',
]
interval: 10s
timeout: 5s
retries: 10
elasticsearch2:
image: elasticsearch:9.3.0
container_name: labrinth-elasticsearch2
networks:
- elasticsearch-mesh
restart: on-failure
depends_on:
elasticsearch-certs:
condition: service_completed_successfully
volumes:
- elasticsearch2-data:/usr/share/elasticsearch/data
- elasticsearch-certs:/usr/share/elasticsearch/config/certs:ro
environment:
- logger.level=WARN
- node.name=elasticsearch2
- cluster.name=labrinth
- cluster.initial_master_nodes=elasticsearch0,elasticsearch1,elasticsearch2
- discovery.seed_hosts=elasticsearch0,elasticsearch1
- bootstrap.memory_lock=false
# auth
- xpack.security.enabled=true
- xpack.security.transport.ssl.enabled=true
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.security.transport.ssl.key=certs/elasticsearch2/elasticsearch2.key
- xpack.security.transport.ssl.certificate=certs/elasticsearch2/elasticsearch2.crt
- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
- ELASTIC_USERNAME=elastic
- ELASTIC_PASSWORD=elastic
mem_limit: 1g
healthcheck:
test:
[
'CMD-SHELL',
'curl -s -u elastic:elastic http://localhost:9200/_cluster/health | grep -qE "\"status\":\"(yellow|green)\""',
]
interval: 10s
timeout: 5s
retries: 10
redis:
image: redis:alpine
container_name: labrinth-redis
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.90.0"
channel = "1.95.0"
profile = "default"
Loading