Skip to content

Commit

Permalink
Fix a bug where in production there are some cards in the about secti…
Browse files Browse the repository at this point in the history
…on without an updated timestamp.

Part of #646.
  • Loading branch information
jkomoros committed Nov 13, 2023
1 parent e79ea55 commit 1fcaf64
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/actions/similarity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type SimilarCardsResponseData = {

const similarCardsCallable = httpsCallable<SimilarCardsRequestData, SimilarCardsResponseData>(functions, 'similarCards');

const similarCards = async (cardID : CardID, lastUpdated : MillisecondsSinceEpoch) : Promise<SimilarCardsResponseData> => {
const similarCards = async (cardID : CardID, lastUpdated? : MillisecondsSinceEpoch) : Promise<SimilarCardsResponseData> => {
if (!QDRANT_ENABLED) {
return {
success: false,
Expand All @@ -83,17 +83,17 @@ const similarCards = async (cardID : CardID, lastUpdated : MillisecondsSinceEpoc
}

const request : SimilarCardsRequestData = {
card_id: cardID,
last_updated: lastUpdated
card_id: cardID
};
if (lastUpdated) request.last_updated = lastUpdated;
const result = await similarCardsCallable(request);
return result.data;
};

const TIME_TO_WAIT_FOR_STALE : MillisecondsSinceEpoch = 10 * 60 * 1000;
const DELAY_FOR_STALE : MillisecondsSinceEpoch = 2.5 * 1000;

const fetchSimilarCards = (cardID : CardID, lastUpdated: MillisecondsSinceEpoch) : ThunkSomeAction => async (dispatch) => {
const fetchSimilarCards = (cardID : CardID, lastUpdated?: MillisecondsSinceEpoch) : ThunkSomeAction => async (dispatch) => {
if (!cardID) return;

const result = await similarCards(cardID, lastUpdated);
Expand Down Expand Up @@ -144,6 +144,6 @@ export const fetchSimilarCardsIfEnabled = (cardID : CardID) : boolean => {
const card = cards[cardID];
if (!card) throw new Error(`Couldn't find card ${cardID}`);
//This will return immediately.
store.dispatch(fetchSimilarCards(cardID, card.updated.toMillis()));
store.dispatch(fetchSimilarCards(cardID, card?.updated?.toMillis()));
return true;
};

0 comments on commit 1fcaf64

Please sign in to comment.