Skip to content

Commit

Permalink
Merge pull request #44 from GeneralMagicio/setDefaultValueForProjectS…
Browse files Browse the repository at this point in the history
…tatuses

Set default value for project statuses
  • Loading branch information
aminlatifi authored Sep 3, 2024
2 parents 5d27480 + a7d51cb commit df8581c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/entities/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ export class Project extends BaseEntity {
@Column({
type: 'enum',
enum: ReviewStatus,
default: ReviewStatus.NotReviewed,
default: ReviewStatus.Listed,
})
reviewStatus: ReviewStatus;

Expand Down
10 changes: 4 additions & 6 deletions src/resolvers/projectResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,10 @@ function createProjectTestCases() {
ORGANIZATION_LABELS.GIVETH,
);

// When creating project, listed is null by default
assert.equal(result.data.data.createProject.listed, null);
assert.equal(result.data.data.createProject.listed, true);
assert.equal(
result.data.data.createProject.reviewStatus,
ReviewStatus.NotReviewed,
ReviewStatus.Listed,
);

assert.equal(
Expand Down Expand Up @@ -568,11 +567,10 @@ function createProjectTestCases() {
ORGANIZATION_LABELS.GIVETH,
);

// When creating project, listed is null by default
assert.equal(result.data.data.createProject.listed, null);
assert.equal(result.data.data.createProject.listed, true);
assert.equal(
result.data.data.createProject.reviewStatus,
ReviewStatus.NotReviewed,
ReviewStatus.Listed,
);

assert.equal(
Expand Down
12 changes: 8 additions & 4 deletions src/resolvers/projectResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1118,8 +1118,8 @@ export class ProjectResolver {
}
project.qualityScore = qualityScore;
project.updatedAt = new Date();
project.listed = null;
project.reviewStatus = ReviewStatus.NotReviewed;
project.listed = true;
project.reviewStatus = ReviewStatus.Listed;

// if (newProjectData.icon !== undefined) {
// project.icon = newProjectData.icon;
Expand Down Expand Up @@ -1364,6 +1364,7 @@ export class ProjectResolver {
}
const slug = await getAppropriateSlug(slugBase);

// if we don't get isDraft, we set the status to active
const status = await this.projectStatusRepository.findOne({
where: {
id: projectInput.isDraft ? ProjStatus.drafted : ProjStatus.active,
Expand Down Expand Up @@ -1418,6 +1419,9 @@ export class ProjectResolver {
verified: false,
giveBacks: false,
adminUser: user,
// make project listed by default
listed: true,
reviewStatus: ReviewStatus.Listed,
});

await project.save();
Expand Down Expand Up @@ -2145,8 +2149,8 @@ export class ProjectResolver {
user,
});

project.listed = null;
project.reviewStatus = ReviewStatus.NotReviewed;
project.listed = true;
project.reviewStatus = ReviewStatus.Listed;

await project.save();

Expand Down

0 comments on commit df8581c

Please sign in to comment.