Skip to content
Merged

Deploy #1775

Show file tree
Hide file tree
Changes from all commits
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
55 changes: 49 additions & 6 deletions apps/backend/Jobs/Character/CharacterAchievementsJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ public override async Task Run(string[] data)
{
var timer = new JankTimer();

if (_query?.AccountId == null)
{
throw new InvalidDataException("AccountId is null");
}

int accountId = _query.AccountId.Value;

string lockKey = string.Format(RedisKeys.AccountAchievements, accountId);
string lockValue = Guid.NewGuid().ToString("N");
try
{
// Attempt to get exclusive scheduler lock
bool lockSuccess = await JobRepository.AcquireLockAsync(lockKey, lockValue, TimeSpan.FromMinutes(1));
if (!lockSuccess)
{
Logger.Debug("Skipping achievements, lock failed");
return;
}
}
catch (Exception ex)
{
Logger.Error(ex, "Kaboom!");
return;
}

// Fetch API data
ApiCharacterAchievements resultData;
var uri = GenerateUri(_query, ApiPath);
Expand All @@ -43,6 +68,17 @@ public override async Task Run(string[] data)
return;
}

// Fetch account data
var paAchievements = await Context.PlayerAccountAchievements.FindAsync(accountId);
if (paAchievements == null)
{
paAchievements = new PlayerAccountAchievements
{
AccountId = accountId,
};
Context.PlayerAccountAchievements.Add(paAchievements);
}

// Fetch character data
var pcAchievements = await Context.PlayerCharacterAchievements.FindAsync(_query.CharacterId);
if (pcAchievements == null)
Expand Down Expand Up @@ -78,6 +114,7 @@ public override async Task Run(string[] data)
RecurseCriteria(criteria, dataAchievement.Criteria?.ChildCriteria);
}

// Achievements go in account data
var sortedAchievements = cheevs
.OrderBy(kvp => kvp.Key)
.ToArray();
Expand All @@ -88,16 +125,19 @@ public override async Task Run(string[] data)
.Select(kvp => kvp.Value)
.ToList();

if (pcAchievements.AchievementIds == null || !achievementIds.SequenceEqual(pcAchievements.AchievementIds))
byte[] compressedAchievementIds = SerializationUtilities.SerializeToBitmap(achievementIds);

if (paAchievements.CompressedAchievementIds == null || !compressedAchievementIds.SequenceEqual(paAchievements.CompressedAchievementIds))
{
pcAchievements.AchievementIds = achievementIds;
paAchievements.CompressedAchievementIds = compressedAchievementIds;
}

if (pcAchievements.AchievementTimestamps == null || !achievementTimestamps.SequenceEqual(pcAchievements.AchievementTimestamps))
if (paAchievements.AchievementTimestamps == null || !achievementTimestamps.SequenceEqual(paAchievements.AchievementTimestamps))
{
pcAchievements.AchievementTimestamps = achievementTimestamps;
paAchievements.AchievementTimestamps = achievementTimestamps;
}

// Criteria go in character data
var sortedCriteria = criteria
.Where(kvp => kvp.Value.Item2 || kvp.Value.Item1 > 0)
.OrderBy(kvp => kvp.Key)
Expand All @@ -112,9 +152,12 @@ public override async Task Run(string[] data)
.Select(kvp => kvp.Value.Item2)
.ToList();

if (pcAchievements.CriteriaIds == null || !criteriaIds.SequenceEqual(pcAchievements.CriteriaIds))
byte[] compressedCriteriaIds = SerializationUtilities.SerializeToBitmap(criteriaIds);

if (pcAchievements.CompressedCriteriaIds == null || !compressedCriteriaIds.SequenceEqual(pcAchievements.CompressedCriteriaIds))
{
pcAchievements.CriteriaIds = criteriaIds;
pcAchievements.CriteriaIds = null;
pcAchievements.CompressedCriteriaIds = compressedCriteriaIds;
}

if (pcAchievements.CriteriaAmounts == null || !criteriaAmounts.SequenceEqual(pcAchievements.CriteriaAmounts))
Expand Down
7 changes: 4 additions & 3 deletions apps/backend/Jobs/Character/CharacterMountsJob.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Net.Http;
using Wowthing.Backend.Models.API.Character;
using Wowthing.Lib.Constants;
using Wowthing.Lib.Models.Player;
using Wowthing.Lib.Models.Query;

Expand All @@ -26,15 +27,15 @@ public override async Task Run(string[] data)

int accountId = _query.AccountId.Value;

string lockKey = $"account_mounts:{accountId}";
string lockKey = string.Format(RedisKeys.AccountMounts, accountId);
string lockValue = Guid.NewGuid().ToString("N");
try
{
// Attempt to get exclusive scheduler lock
bool lockSuccess = await JobRepository.AcquireLockAsync(lockKey, lockValue, TimeSpan.FromMinutes(1));
if (!lockSuccess)
{
Logger.Debug("Skipping pets, lock failed");
Logger.Debug("Skipping mounts, lock failed");
return;
}
}
Expand Down Expand Up @@ -63,7 +64,7 @@ public override async Task Run(string[] data)
return;
}

// Fetch character data
// Fetch account data
var paMounts = await Context.PlayerAccountMounts.FindAsync(accountId);
if (paMounts == null)
{
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/components/home/view-switcher/Delves.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import { delveMap, type Delve } from '@/data/delve';
import { iconLibrary } from '@/shared/icons';
import { settingsState } from '@/shared/state/settings.svelte';
import { componentTooltip } from '@/shared/utils/tooltips';
import { userState } from '@/user-home/state/user';
import { dynamicDataStore } from '@/user-home/stores/dynamicData';

import DelvesTooltip from './DelvesTooltip.svelte';
import IconifyWrapper from '@/shared/components/images/IconifyWrapper.svelte';
import { settingsState } from '@/shared/state/settings.svelte';

let delves = $derived.by(() => {
const dynamicDelves = dynamicDataStore.getCached(userState.general.allRegions[0]).delves;
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/data/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const imageStrings: Record<string, string> = {
};

export const iconStrings: Record<string, Icon> = {
dungeon: iconLibrary.faDungeon,
exclamation: iconLibrary.mdiExclamationThick,
fire: iconLibrary.mdiFire,
item: iconLibrary.mdiGiftOutline,
Expand Down
2 changes: 2 additions & 0 deletions apps/frontend/data/tasks/events/timewalking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const eventTimewalking: Task = {
{
key: 'dungeons',
name: 'Dungeons',
icon: ':time::dungeon:',
minimumLevel: 10,
requiredHolidays: timewalkingHolidays,
questReset: DbResetType.Weekly,
Expand Down Expand Up @@ -50,6 +51,7 @@ export const eventTimewalking: Task = {
{
key: 'dungeonItem',
name: 'Dungeon Item',
icon: ':time::item:',
requiredHolidays: timewalkingHolidays,
questReset: DbResetType.Weekly,
questIds: [
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/shared/icons/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export { default as mdiGiftOutline } from '~icons/mdi/gift-outline';
export { default as mdiGhost } from '~icons/mdi/ghost';
export { default as mdiHammerWrench } from '~icons/mdi/hammer-wrench';
export { default as mdiHomeOutline } from '~icons/mdi/home-outline';
export { default as mdiHourglass } from '~icons/mdi/hourglass';
export { default as mdiImageBrokenVariant } from '~icons/mdi/image-broken-variant';
export { default as mdiLetterC } from '~icons/mdi/alpha-c-circle-outline';
export { default as mdiLetterD } from '~icons/mdi/alpha-d-circle-outline';
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/shared/icons/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const uiIcons = {
starEmpty: iconLibrary.mdiStarOutline,
starHalf: iconLibrary.mdiStarHalfFull,
starFull: iconLibrary.mdiStarFace,
time: iconLibrary.mdiHourglass,
yes: iconLibrary.mdiCheck,

circleD: iconLibrary.mynauiLetterDCircle,
Expand Down
3 changes: 3 additions & 0 deletions packages/csharp-lib/Constants/RedisKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public static class RedisKeys
public const string AuctionsLock = "lock:auctions";
public const string CheckedAuctions = "checked_auctions";

public const string AccountAchievements = "account:{0}:achievements";
public const string AccountMounts = "account:{0}:mounts";

public const string CharacterJobCounter = "character:{0}:jobs";

public const string UserAchievements = "user:{0}:achievements";
Expand Down
1 change: 1 addition & 0 deletions packages/csharp-lib/Contexts/WowDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class WowDbContext : IdentityDbContext<ApplicationUser, IdentityRole<long
public DbSet<GlobalDailies> GlobalDailies { get; set; }

public DbSet<PlayerAccount> PlayerAccount { get; set; }
public DbSet<PlayerAccountAchievements> PlayerAccountAchievements { get; set; }
public DbSet<PlayerAccountAddonData> PlayerAccountAddonData { get; set; }
public DbSet<PlayerAccountGoldSnapshot> PlayerAccountGoldSnapshot { get; set; }
public DbSet<PlayerAccountHeirlooms> PlayerAccountHeirlooms { get; set; }
Expand Down
Loading
Loading