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

Next release #1134

Merged
merged 58 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2e384c3
Merge pull request #1113 from Giveth/master
aminlatifi Sep 3, 2023
3867ac5
Return list of active campaigns in projectBySlug web service
mohammadranjbarz Sep 4, 2023
302f253
rewrite totalReceived query
CarlosQ96 Sep 4, 2023
ea91acc
Merge pull request #1114 from Giveth/f_1051_return_list_of_campaigns_…
mohammadranjbarz Sep 5, 2023
f0c648e
Update totalReceived of project owners correctly after verifying dona…
mohammadranjbarz Sep 5, 2023
89c5c9e
Update totalReceived of project owners correctly after verifying dona…
mohammadranjbarz Sep 6, 2023
a357abf
Delete test user after some test cases
mohammadranjbarz Sep 6, 2023
a686f29
Fix Auth microservice address in config
mohammadranjbarz Sep 6, 2023
0092f5a
Resolve merge conflicts
mohammadranjbarz Sep 6, 2023
5175008
Add cache to qfRound estimated matching queries
mohammadranjbarz Sep 6, 2023
bc25160
Merge pull request #1121 from Giveth/f_3021_update_totalReceived_of_p…
CarlosQ96 Sep 6, 2023
60416c8
removed unused code
CarlosQ96 Sep 7, 2023
f4c0412
Add QF_ROUND_ESTIMATED_MATCHING_CACHE_DURATION to example.env
mohammadranjbarz Sep 7, 2023
812c554
add eligible donations to qfround entity
CarlosQ96 Sep 10, 2023
414eb01
add tests for qfround eligible donations
CarlosQ96 Sep 11, 2023
99a5e58
add adminjs eligiblenetworks editable on qfround
CarlosQ96 Sep 11, 2023
e953447
Update staging-pipeline.yml
mhmdksh Sep 11, 2023
e89a515
Merge pull request #1122 from Giveth/f_1103_cache_qf_related_queries
mohammadranjbarz Sep 11, 2023
74a1224
add labels to the networks in adminjs for qfround
CarlosQ96 Sep 13, 2023
ca31852
add migration to fill in previous networkIds in qfrounds
CarlosQ96 Sep 14, 2023
c4f8012
Merge pull request #1124 from Giveth/feature_add_network_elegibility_…
CarlosQ96 Sep 14, 2023
c851c2a
fix eligible donations migration
CarlosQ96 Sep 14, 2023
7031640
fix migration table names for qfround networks
CarlosQ96 Sep 14, 2023
1819744
fix migration file for eligible networks
CarlosQ96 Sep 14, 2023
ed3025a
fix qfround fill networks migration
CarlosQ96 Sep 14, 2023
ae9f96a
add query for knowing if wallet was used
CarlosQ96 Sep 16, 2023
7a0b6c1
improve query for user related address
CarlosQ96 Sep 17, 2023
1a46487
unify project counts in userByAddress and projectsByUserId
CarlosQ96 Sep 19, 2023
0757d1c
Merge pull request #1129 from Giveth/feature_unify_project_count
CarlosQ96 Sep 19, 2023
5fec931
improve condition for projectCount
CarlosQ96 Sep 19, 2023
28c1299
fix projectCount query
CarlosQ96 Sep 19, 2023
97e6ac2
Merge branch 'add_logs_for_update_reminder' into staging
mohammadranjbarz Sep 25, 2023
6adbc81
Merge branch 'staging' of github.com:Giveth/impact-graph into staging
mohammadranjbarz Sep 25, 2023
db91549
Add Other types of campaigns to projectBySlug webservice
mohammadranjbarz Sep 27, 2023
704cb98
Change name of fetchProjectsBySlugQuery field
mohammadranjbarz Sep 28, 2023
3e2d607
Merge branch 'master' into staging
mohammadranjbarz Sep 28, 2023
304efe8
add qfFilter with estimatedMatchingView
CarlosQ96 Sep 29, 2023
484f6ff
add sorting by qfround raised funds
CarlosQ96 Oct 2, 2023
6519399
Implement doesDonatedToProjectInQfRound webservice
mohammadranjbarz Oct 2, 2023
0325f7c
Move caching project campaign slugs process to a separated worker
mohammadranjbarz Oct 2, 2023
86fea20
Merge pull request #1139 from Giveth/f_1138_implement_does_donated_to…
mohammadranjbarz Oct 2, 2023
3620351
fix relationships for estimated matching filters
CarlosQ96 Oct 3, 2023
4ca466b
Merge branch 'staging' into feature_new_qf_filters_table
CarlosQ96 Oct 3, 2023
05eeae0
Merge pull request #1136 from Giveth/f_1051_fix_add_campaigns_to_proj…
mohammadranjbarz Oct 3, 2023
97d1a2f
Merge pull request #1137 from Giveth/feature_new_qf_filters_table
CarlosQ96 Oct 3, 2023
a9ad8f9
Put campaign projects cache in redis instead of saving that in memory
mohammadranjbarz Oct 5, 2023
cafffc9
Change default value of CACHE_PROJECT_CAMPAIGNS_CRONJOB_EXPRESSION
mohammadranjbarz Oct 5, 2023
6821e05
Merge pull request #1144 from Giveth/put_campaign_projects_cache_in_r…
CarlosQ96 Oct 5, 2023
fb0c892
change to leftJoin on estimatedMatchingTable
CarlosQ96 Oct 5, 2023
1cca468
Merge pull request #1145 from Giveth/hotfix_qfround_sorting_to_includ…
CarlosQ96 Oct 5, 2023
f756b2e
fix tests
CarlosQ96 Oct 5, 2023
52fcca7
modify qfround filter join
CarlosQ96 Oct 5, 2023
21e2a98
order null donations to last position
CarlosQ96 Oct 5, 2023
81501d3
Add some logs
mohammadranjbarz Oct 7, 2023
5e966de
Change default value of CACHE_PROJECT_CAMPAIGNS_CRONJOB_EXPRESSION
mohammadranjbarz Oct 7, 2023
804ef4c
Put calling updateInstantPowerBalances() in try..catch...
mohammadranjbarz Oct 7, 2023
dc310ed
Add comment
mohammadranjbarz Oct 8, 2023
c65575f
1.17.0
mohammadranjbarz Oct 8, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ jobs:
OPTIMISTIC_SCAN_API_KEY: ${{ secrets.OPTIMISTIC_SCAN_API_KEY }}
CELO_SCAN_API_KEY: ${{ secrets.CELO_SCAN_API_KEY }}
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}
DROP_DATABASE: ${{ secrets.DROP_DATABASE }}

publish:
needs: test
Expand Down
8 changes: 8 additions & 0 deletions config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,11 @@ POWER_BALANCE_AGGREGATOR_ADAPTER=powerBalanceAggregator
#POWER_BALANCE_AGGREGATOR_ADAPTER=mock
NUMBER_OF_BALANCE_AGGREGATOR_BATCH=20

# OPTIONAL - default: 60000 (1 minute
QF_ROUND_ESTIMATED_MATCHING_CACHE_DURATION=60000

# OPTIONAL - default: Every 10 minutes
PROJECT_CAMPAIGNS_CACHE_DURATION=600000

# OPTIONAL - default: *0 */5 * * * ( Every 5 minutes)
CACHE_PROJECT_CAMPAIGNS_CRONJOB_EXPRESSION=0 */5 * * * *
10 changes: 10 additions & 0 deletions config/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,13 @@ OPTIMISM_NODE_HTTP_URL=https://optimism-mainnet.public.blastapi.io
BALANCE_AGGREGATOR_BASE_URL=https://dev.serve.giveth.io/givpower-balance-aggregator
POWER_BALANCE_AGGREGATOR_ADAPTER=mock
NUMBER_OF_BALANCE_AGGREGATOR_BATCH=7


# ! millisecond cache, if we increase cache in test ENV we might get some errors in tests
QF_ROUND_ESTIMATED_MATCHING_CACHE_DURATION=1
# ! millisecond cache, if we increase cache in test ENV we might get some errors in tests
PROJECT_CAMPAIGNS_CACHE_DURATION=1


# OPTIONAL - default: *0 */5 * * * ( Every 5 minutes)
CACHE_PROJECT_CAMPAIGNS_CRONJOB_EXPRESSION=0 */5 * * * *
16 changes: 16 additions & 0 deletions migration/1694295208252-AddEligibleNetworksToQfRoundEntity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';

export class AddEligibleNetworksToQfRoundEntity1694295208252
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE public.qf_round
ADD COLUMN IF NOT EXISTS "eligibleNetworks" integer array DEFAULT ARRAY[]::integer[]
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropColumn('qf_round', 'eligibleNetworks');
}
}
32 changes: 32 additions & 0 deletions migration/1694635872128-AddEligibleNetworksToPreviousQfRounds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import config from '../src/config';

export class AddEligibleNetworksToPreviousQfRounds1694635872128
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
const environment = config.get('ENVIRONMENT') as string;

// Define the eligible network IDs based on the conditions
const eligibleNetworks =
environment !== 'production'
? [1, 3, 5, 100, 137, 10, 420, 56, 42220, 44787] // Include testnets for staging
: [1, 137, 56, 42220, 100, 10]; // Exclude testnets for non-staging

// Update the "qf_round" table with the new eligibleNetworks values
await queryRunner.query(
`
UPDATE public.qf_round
SET "eligibleNetworks" = $1
`,
[eligibleNetworks],
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
UPDATE public.qf_round
SET "eligibleNetworks" = '{}'
`);
}
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "giveth-graphql-api",
"version": "1.16.1",
"version": "1.17.0",
"description": "Backend GraphQL server for Giveth originally forked from Topia",
"main": "./dist/index.js",
"dependencies": {
Expand Down
34 changes: 30 additions & 4 deletions src/entities/ProjectEstimatedMatchingView.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import { Entity, Column, Index, PrimaryColumn } from 'typeorm';
import { Field, ObjectType } from 'type-graphql';
import {
Entity,
Column,
Index,
PrimaryColumn,
BaseEntity,
ViewEntity,
ManyToOne,
RelationId,
ViewColumn,
JoinColumn,
} from 'typeorm';
import { Project } from './project';

@Entity({ name: 'project_estimated_matching_view' })
@ViewEntity('project_estimated_matching_view', { synchronize: false })
@Index('project_estimated_matching_view_project_id_qfround_id', [
'projectId',
'qfRoundId',
Expand All @@ -13,28 +26,41 @@ import { Entity, Column, Index, PrimaryColumn } from 'typeorm';
@Index('project_estimated_matching_view_unique_donation_count', [
'uniqueDonationCount',
])
export class ProjectEstimatedMatchingView {
// Project ID associated with the donations
@ObjectType()
export class ProjectEstimatedMatchingView extends BaseEntity {
@Field(type => Project)
@ManyToOne(type => Project, project => project.projectEstimatedMatchingView)
@JoinColumn({ referencedColumnName: 'id' })
project: Project;

@Field()
@ViewColumn()
@PrimaryColumn()
projectId: number;

// QF Round ID associated with the donations
@ViewColumn()
@Field()
@PrimaryColumn()
qfRoundId: number;

// Sum of the square root of the value in USD of the donations
@ViewColumn()
@Column('double precision')
sqrtRootSum: number;

// Count of unique donations per user per project per QF round
@ViewColumn()
@Column('int')
uniqueDonationCount: number;

// Sum of the value in USD of the donations for active QF rounds where the donation status is verified
@ViewColumn()
@Column('double precision')
sumValueUsd: number;

// Count of unique donors who have verified donations for each project
@ViewColumn()
@Column('int')
uniqueDonorsCount: number;
}
17 changes: 17 additions & 0 deletions src/entities/campaign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,26 @@ export enum CampaignFilterField {
}

export enum CampaignType {
// https://github.com/Giveth/impact-graph/blob/staging/docs/campaignsInstruction.md

// In these type of projects we pick some projects to show them in campaign,
// for instance for Turkey earthquake we pick some projects.
// so we just need to add slug of those projects in Related Projects Slugs and in
// what order we add them they will be shown in frontend
ManuallySelected = 'ManuallySelected',

// Sometimes in a campaign we just want to show projects in an specified order,
// for instance we can create a campaign like ** Check projects that received most likes** so for
// this campaign you set SortField as campaign type and then you can use one of below sorting fields
SortField = 'SortField',

// Sometimes we need to filter some projects in a campaign,
// for instance Let's verified projects that accept funds on Gnosis chain,
// for this we can Add verified and acceptFundOnGnosis filters
FilterFields = 'FilterFields',

// Some campaigns don't include any project in them and they are just some banner
// like Feeling $nice? campaign in below image
WithoutProjects = 'WithoutProjects',
}

Expand Down
2 changes: 2 additions & 0 deletions src/entities/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { ProjectInstantPowerView } from '../views/projectInstantPowerView';
import { QfRound } from './qfRound';
import { ReferredEvent } from './referredEvent';
import { QfRoundHistory } from './qfRoundHistory';
import { ProjectEstimatedMatchingView } from './ProjectEstimatedMatchingView';

export const getEntities = (): DataSourceOptions['entities'] => {
return [
Expand Down Expand Up @@ -81,6 +82,7 @@ export const getEntities = (): DataSourceOptions['entities'] => {
LastSnapshotProjectPowerView,
ProjectInstantPowerView,
ProjectUserInstantPowerView,
ProjectEstimatedMatchingView,

// historic snapshots
PowerSnapshotHistory,
Expand Down
14 changes: 13 additions & 1 deletion src/entities/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import {
getQfRoundTotalProjectsDonationsSum,
} from '../repositories/qfRoundRepository';
import { EstimatedMatching } from '../types/qfTypes';
import { Campaign } from './campaign';
import { ProjectEstimatedMatchingView } from './ProjectEstimatedMatchingView';
// tslint:disable-next-line:no-var-requires
const moment = require('moment');

Expand All @@ -75,6 +77,7 @@ export enum SortingField {
QualityScore = 'QualityScore',
GIVPower = 'GIVPower',
InstantBoosting = 'InstantBoosting',
ActiveQfRoundRaisedFunds = 'ActiveQfRoundRaisedFunds',
}

export enum FilterField {
Expand All @@ -101,7 +104,6 @@ export enum OrderField {
QualityScore = 'qualityScore',
Verified = 'verified',
Reactions = 'totalReactions',
Traceable = 'traceCampaignId',
Donations = 'totalDonations',
TraceDonations = 'totalTraceDonations',
AcceptGiv = 'givingBlocksId',
Expand Down Expand Up @@ -341,6 +343,13 @@ export class Project extends BaseEntity {
@OneToMany(type => SocialProfile, socialProfile => socialProfile.project)
socialProfiles?: SocialProfile[];

@Field(type => [ProjectEstimatedMatchingView], { nullable: true })
@OneToMany(
type => ProjectEstimatedMatchingView,
projectEstimatedMatchingView => projectEstimatedMatchingView.project,
)
projectEstimatedMatchingView?: ProjectEstimatedMatchingView[];

@Field(type => Float)
@Column({ type: 'real' })
totalDonations: number;
Expand Down Expand Up @@ -390,6 +399,9 @@ export class Project extends BaseEntity {
@Field({ nullable: true })
reaction?: Reaction;

@Field(type => [Campaign], { nullable: true })
campaigns: Campaign[];

// only projects with status active can be listed automatically
static pendingReviewSince(maximumDaysForListing: Number) {
const maxDaysForListing = moment()
Expand Down
14 changes: 13 additions & 1 deletion src/entities/qfRound.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Field, ID, ObjectType } from 'type-graphql';
import { Field, ID, ObjectType, Int } from 'type-graphql';
import {
PrimaryGeneratedColumn,
Column,
Expand Down Expand Up @@ -36,6 +36,10 @@ export class QfRound extends BaseEntity {
@Column()
minimumPassportScore: number;

@Field(type => [Int], { nullable: true }) // Define the new field as an array of integers
@Column('integer', { array: true, default: [] })
eligibleNetworks: number[];

@Field(type => Date)
@Column()
beginDate: Date;
Expand All @@ -52,4 +56,12 @@ export class QfRound extends BaseEntity {

@ManyToMany(type => Project, project => project.qfRounds)
projects: Project[];

// only projects with status active can be listed automatically
isEligibleNetwork(donationNetworkId: number): Boolean {
// when not specified, all are valid
if (this.eligibleNetworks.length === 0) return true;

return this.eligibleNetworks.includes(donationNetworkId);
}
}
Loading