Skip to content

Commit

Permalink
feat: add topReaderBadge to alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
omBratteng committed Oct 31, 2024
1 parent cdfda28 commit a76190a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/entity/Alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export class Alerts {

bootPopup?: boolean;

@Column({ type: 'uuid', nullable: true })
topReaderBadge?: string | null;

@OneToOne('User', {
lazy: true,
onDelete: 'CASCADE',
Expand All @@ -83,4 +86,5 @@ export const ALERTS_DEFAULT: Omit<Alerts, 'userId' | 'flags' | 'user'> = {
lastBootPopup: null,
bootPopup: false,
showRecoverStreak: false,
topReaderBadge: null,
};
13 changes: 13 additions & 0 deletions src/migration/1730379505031-AlertsTopReader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class AlertsTopReader1730379505031 implements MigrationInterface {
name = 'AlertsTopReader1730379505031'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "alerts" ADD "topReaderBadge" uuid`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "alerts" DROP COLUMN "topReaderBadge"`);
}
}
16 changes: 16 additions & 0 deletions src/schema/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface GQLUpdateAlertsInput extends Partial<GQLAlerts> {
filter?: boolean;
myFeed?: string;
lastBootPopup?: Date;
topReaderBadge?: null;
}

export const typeDefs = /* GraphQL */ `
Expand Down Expand Up @@ -85,6 +86,11 @@ export const typeDefs = /* GraphQL */ `
Date of the last time user dismissed or answered the feed survey
"""
lastFeedSettingsFeedback: DateTime
"""
UUID of the last top reader badge for the user
"""
topReaderBadge: String
}
input UpdateAlertsInput {
Expand Down Expand Up @@ -137,6 +143,11 @@ export const typeDefs = /* GraphQL */ `
Date of the last time user saw a boot popup
"""
lastBootPopup: DateTime
"""
UUID of the last top reader badge for the user
"""
topReaderBadge: String
}
extend type Mutation {
Expand Down Expand Up @@ -196,6 +207,11 @@ export const updateAlerts = async (
await insertOrIgnoreAction(con, userId, UserActionType.MyFeed);
}

// Make sure that top reader badge is nulled out, and not set to some other value
if (data?.topReaderBadge && data.topReaderBadge !== null) {
data.topReaderBadge = null;
}

if (!alerts) {
return saveReturnAlerts(
await repo.save({
Expand Down

0 comments on commit a76190a

Please sign in to comment.