mirror of
https://github.com/modrinth/code.git
synced 2026-07-31 21:26:40 +00:00
chore: fixes
This commit is contained in:
@@ -68,10 +68,8 @@ pub async fn update_many(
|
||||
.await
|
||||
.wrap_internal_err("failed to fetch subscriptions to update")?;
|
||||
|
||||
let mut subscriptions_by_target = subscriptions
|
||||
.iter()
|
||||
.map(|update| (update.target, None))
|
||||
.collect::<HashMap<SubscriptionTarget, Option<DBUserSubscription>>>();
|
||||
let mut subscriptions_by_target =
|
||||
HashMap::<SubscriptionTarget, DBUserSubscription>::new();
|
||||
|
||||
// Creates a map of subscription "key" -> it's DB representation.
|
||||
for subscription in found_subscriptions {
|
||||
@@ -88,25 +86,22 @@ pub async fn update_many(
|
||||
server_id,
|
||||
};
|
||||
|
||||
if let Some(entry) = subscriptions_by_target.get_mut(&target) {
|
||||
*entry = Some(subscription);
|
||||
}
|
||||
subscriptions_by_target.insert(target, subscription);
|
||||
}
|
||||
|
||||
for update in subscriptions {
|
||||
let Some(Some(subscription)) =
|
||||
let Some(subscription) =
|
||||
subscriptions_by_target.get_mut(&update.target)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
// Update the subscription region
|
||||
if let Some(m) = subscription.metadata.as_mut() {
|
||||
if let SubscriptionMetadata::Pyro { region, .. } = m {
|
||||
if let Some(new_region) = update.update_region.clone() {
|
||||
*region = Some(new_region);
|
||||
}
|
||||
}
|
||||
if let Some(SubscriptionMetadata::Pyro { region, .. }) =
|
||||
subscription.metadata.as_mut()
|
||||
&& let Some(new_region) = update.update_region.clone()
|
||||
{
|
||||
*region = Some(new_region);
|
||||
}
|
||||
|
||||
subscription.upsert(&mut txn).await?;
|
||||
|
||||
Reference in New Issue
Block a user