Skip to content

Commit

Permalink
Fix external_achievements (#6667)
Browse files Browse the repository at this point in the history
  • Loading branch information
megrogan authored Oct 24, 2024
1 parent 139f5b6 commit 94a060b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions backend/canisters/user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Don't remove external achievements on expiry ([#6588](https://github.com/open-chat-labs/open-chat/pull/6588))

### Fixed

- Fix `last_updated` field of `external_achievements` ([#6667](https://github.com/open-chat-labs/open-chat/pull/6667))

## [[2.0.1384](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1384-user_index)] - 2024-10-11

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ fn external_achievements_impl(args: Args, state: &RuntimeState) -> Response {
last_updated = max([
last_updated,
achievement.registered,
achievement.expires,
achievement.budget_exhausted.unwrap_or_default(),
])
.unwrap();
Expand Down
11 changes: 10 additions & 1 deletion frontend/openchat-agent/src/utils/caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import type { CryptocurrencyContent } from "openchat-shared";
import type { PrizeContent } from "openchat-shared";
import type { P2PSwapContent } from "openchat-shared";

const CACHE_VERSION = 118;
const CACHE_VERSION = 119;
const EARLIEST_SUPPORTED_MIGRATION = 115;
const MAX_INDEX = 9999999999;

Expand Down Expand Up @@ -199,6 +199,14 @@ async function clearChatAndGroups(
await clearGroupDetailsStore(_db, _principal, tx);
}

async function clearExternalAchievements(
_db: IDBPDatabase<ChatSchema>,
_principal: Principal,
tx: IDBPTransaction<ChatSchema, StoreNames<ChatSchema>[], "versionchange">,
) {
await tx.objectStore("externalAchievements").clear();
}

const migrations: Record<number, MigrationFunction<ChatSchema>> = {
115: clearEverything,
116: async (db, principal, transaction) => {
Expand All @@ -214,6 +222,7 @@ const migrations: Record<number, MigrationFunction<ChatSchema>> = {
createActivityFeed(db, principal, tx),
]);
},
119: clearExternalAchievements,
};

async function migrate(
Expand Down

0 comments on commit 94a060b

Please sign in to comment.