Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: the current implementation of ComposeDatabase still allows conc… #3186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
42 changes: 28 additions & 14 deletions database-client/src/composeDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,14 @@ export class ComposeDatabase implements WriteOnlySecondaryDataStorageBase {
// It should be safe to ignore error error, they should be logged in the called functions
}
}
await this.composeImpl.getPassportWithWrapper();
const promiseToReturn = this.composeImpl.addStamps(stamps);
this.lastOp = promiseToReturn;
return promiseToReturn;
const opFunc = async (): Promise<SecondaryStorageAddResponse[]> => {
await this.composeImpl.getPassportWithWrapper();
const promiseToReturn = this.composeImpl.addStamps(stamps);
return promiseToReturn;
};
const op = opFunc();
this.lastOp = op;
return op;
};

patchStamps = async (stampPatches: StampPatch[]): Promise<SecondaryStorageBulkPatchResponse> => {
Expand All @@ -119,10 +123,14 @@ export class ComposeDatabase implements WriteOnlySecondaryDataStorageBase {
// It should be safe to ignore error error, they should be logged in the called functions
}
}
await this.composeImpl.getPassportWithWrapper();
const promiseToReturn = this.composeImpl.patchStamps(stampPatches);
this.lastOp = promiseToReturn;
return promiseToReturn;
const opFunc = async (): Promise<SecondaryStorageBulkPatchResponse> => {
await this.composeImpl.getPassportWithWrapper();
const promiseToReturn = this.composeImpl.patchStamps(stampPatches);
return promiseToReturn;
};
const op = opFunc();
this.lastOp = op;
return op;
};

deleteStamps = async (providers: PROVIDER_ID[]): Promise<SecondaryStorageDeleteResponse[]> => {
Expand All @@ -133,10 +141,14 @@ export class ComposeDatabase implements WriteOnlySecondaryDataStorageBase {
// It should be safe to ignore error error, they should be logged in the called functions
}
}
// No need to call this.composeImpl.getPassportWithWrapper(); as it is already called in the deleteStamps function
const promiseToReturn = this.composeImpl.deleteStamps(providers);
this.lastOp = promiseToReturn;
return promiseToReturn;
const opFunc = async (): Promise<SecondaryStorageDeleteResponse[]> => {
// No need to call this.composeImpl.getPassportWithWrapper(); as it is already called in the deleteStamps function
const promiseToReturn = this.composeImpl.deleteStamps(providers);
return promiseToReturn;
};
const op = opFunc();
this.lastOp = op;
return op;
};

getPassport = async (): Promise<PassportLoadResponse> => {
Expand Down Expand Up @@ -508,6 +520,8 @@ export class ComposeDatabaseImpl implements WriteOnlySecondaryDataStorageBase {
}

const wrappers = (result?.data?.viewer?.gitcoinPassportStampWrapperList?.edges || []).map((edge) => edge.node);
console.log(`[ComposeDB] ${this.did} getPassportWithWrapper returns`, wrappers);
this.logger.info(`[ComposeDB] ${this.did} getPassportWithWrapper returns`, { wrappers });
return wrappers;
}

Expand All @@ -521,8 +535,8 @@ export class ComposeDatabaseImpl implements WriteOnlySecondaryDataStorageBase {
credential: formatCredentialFromCeramic(wrapper.vc),
}));

console.log(`[ComposeDB] ${this.did} getPassport:`, stamps);
this.logger.info(`[ComposeDB] ${this.did} getPassport`, { stamps });
console.log(`[ComposeDB] ${this.did} getPassport stamps:`, stamps);
this.logger.info(`[ComposeDB] ${this.did} getPassport stamps`, { stamps });
return {
status: "Success",
passport: {
Expand Down
Loading