Skip to content

Commit

Permalink
refactor: expose lastProcessdIpfsHash field
Browse files Browse the repository at this point in the history
  • Loading branch information
jtourkos committed Dec 5, 2024
1 parent ee1efce commit ca3a109
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/dataLoaders/sqlQueries/dripListsQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function getDripListsByIds(
dripListIds: DripListId[],
) {
const baseSQL = (schema: DbSchema) => `
SELECT "id", "isValid", "isVisible", "ownerAddress", "ownerAccountId", "name", "latestVotingRoundId", "description", "creator", "previousOwnerAddress", "createdAt", "updatedAt", '${schema}' AS chain
SELECT "id", "isValid", "isVisible", "ownerAddress", "ownerAccountId", "name", "latestVotingRoundId", "description", "creator", "previousOwnerAddress", "createdAt", "updatedAt", "lastProcessedIpfsHash", '${schema}' AS chain
FROM "${schema}"."DripLists"
`;

Expand Down
6 changes: 3 additions & 3 deletions src/dataLoaders/sqlQueries/projectsQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function getProjectByUrl(
url: string,
): Promise<ProjectDataValues[]> {
const baseSQL = (schema: DbSchema) => `
SELECT "id", "isValid", "isVisible", "name", "verificationStatus"::TEXT, "claimedAt", "forge"::TEXT, "ownerAddress", "ownerAccountId", "url", "emoji", "avatarCid", "color", "description", "createdAt", "updatedAt", '${schema}' AS chain
SELECT "id", "isValid", "isVisible", "name", "verificationStatus"::TEXT, "claimedAt", "forge"::TEXT, "ownerAddress", "ownerAccountId", "url", "emoji", "avatarCid", "color", "description", "createdAt", "updatedAt", "lastProcessedIpfsHash", '${schema}' AS chain
FROM "${schema}"."GitProjects"
`;

Expand Down Expand Up @@ -43,7 +43,7 @@ async function getProjectsByFilter(
): Promise<ProjectDataValues[]> {
const baseSQL = (schema: DbSchema) =>
`SELECT
"id", "isValid", "isVisible", "name", "verificationStatus"::TEXT, "claimedAt", "forge"::TEXT, "ownerAddress", "ownerAccountId", "url", "emoji", "avatarCid", "color", "description", "createdAt", "updatedAt", '${schema}' AS chain
"id", "isValid", "isVisible", "name", "verificationStatus"::TEXT, "claimedAt", "forge"::TEXT, "ownerAddress", "ownerAccountId", "url", "emoji", "avatarCid", "color", "description", "createdAt", "updatedAt", "lastProcessedIpfsHash", '${schema}' AS chain
FROM "${schema}"."GitProjects" `;

const conditions: string[] = ['"isValid" = true'];
Expand Down Expand Up @@ -91,7 +91,7 @@ async function getProjectsByIds(
projectIds: ProjectId[],
): Promise<ProjectDataValues[]> {
const baseSQL = (schema: DbSchema) => `
SELECT "id", "isValid", "isVisible", "name", "verificationStatus"::TEXT, "claimedAt", "forge"::TEXT, "ownerAddress", "ownerAccountId", "url", "emoji", "avatarCid", "color", "description", "createdAt", "updatedAt", '${schema}' AS chain
SELECT "id", "isValid", "isVisible", "name", "verificationStatus"::TEXT, "claimedAt", "forge"::TEXT, "ownerAddress", "ownerAccountId", "url", "emoji", "avatarCid", "color", "description", "createdAt", "updatedAt", "lastProcessedIpfsHash", '${schema}' AS chain
FROM "${schema}"."GitProjects"
`;

Expand Down
5 changes: 5 additions & 0 deletions src/drip-list/DripListModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class DripListModel extends Model<
public declare previousOwnerAddress: AddressLike;
public declare latestVotingRoundId: UUID | null;
public declare isVisible: boolean;
public declare lastProcessedIpfsHash: string | null;

public static initialize(sequelize: Sequelize): void {
this.init(
Expand Down Expand Up @@ -68,6 +69,10 @@ export default class DripListModel extends Model<
type: DataTypes.BOOLEAN,
allowNull: false,
},
lastProcessedIpfsHash: {
type: DataTypes.TEXT,
allowNull: true,
},
},
{
sequelize,
Expand Down
2 changes: 2 additions & 0 deletions src/drip-list/dripListResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ const dripListResolvers = {
parentDripListInfo: { dripListChain, dripListId },
}: ResolverDripListData) =>
getLatestMetadataHashOnChain(dripListId, dripListChain),
lastProcessedIpfsHash: (dripListData: ResolverDripListData) =>
dripListData.lastProcessedIpfsHash,
},
};

Expand Down
1 change: 1 addition & 0 deletions src/drip-list/dripListTypeDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const dripListTypeDef = gql`
totalEarned: [Amount!]!
latestMetadataIpfsHash: String
isVisible: Boolean!
lastProcessedIpfsHash: String
}
input DripListWhereInput {
Expand Down
5 changes: 5 additions & 0 deletions src/project/ProjectModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class ProjectModel extends Model<
public declare description: string | null;
public declare verificationStatus: ProjectVerificationStatus;
public declare isVisible: boolean;
public declare lastProcessedIpfsHash: string | null;

public declare claimedAt: Date | null;

Expand Down Expand Up @@ -104,6 +105,10 @@ export default class ProjectModel extends Model<
type: DataTypes.BOOLEAN,
allowNull: false,
},
lastProcessedIpfsHash: {
type: DataTypes.TEXT,
allowNull: true,
},
},
{
sequelize,
Expand Down
2 changes: 2 additions & 0 deletions src/project/projectResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ const projectResolvers = {
parentProjectInfo: { projectId, projectChain },
}: ResolverUnClaimedProjectData) =>
getLatestMetadataHashOnChain(projectId, projectChain),
lastProcessedIpfsHash: (projectData: ResolverClaimedProjectData) =>
projectData.lastProcessedIpfsHash,
},
UnClaimedProjectData: {
verificationStatus: (projectData: ResolverUnClaimedProjectData) =>
Expand Down
1 change: 1 addition & 0 deletions src/project/projectTypeDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const projectTypeDef = gql`
totalEarned: [Amount!]!
withdrawableBalances: [WithdrawableBalance!]!
latestMetadataIpfsHash: String!
lastProcessedIpfsHash: String
}
type UnClaimedProjectData {
Expand Down
1 change: 1 addition & 0 deletions src/project/projectUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function mapClaimedProjectChainData(
totalEarned: [], // Will be populated by the resolver.
withdrawableBalances: [], // Will be populated by the resolver.
latestMetadataIpfsHash: '', // Will be populated by the resolver.
lastProcessedIpfsHash: project.lastProcessedIpfsHash,
} as ResolverClaimedProjectData;
}

Expand Down

0 comments on commit ca3a109

Please sign in to comment.