Skip to content

Commit

Permalink
(fix) index
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Nov 26, 2023
1 parent b0ec255 commit f79f1a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/backend/migration/1700902349231-add-bday-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class AddBdayIndex1700902349231 {
name = 'AddBdayIndex1700902349231'

async up(queryRunner) {
await queryRunner.query(`CREATE INDEX "IDX_de22cd2b445eee31ae51cdbe99" ON "user_profile" ("birthday")`);
await queryRunner.query(`CREATE INDEX "IDX_de22cd2b445eee31ae51cdbe99" ON "user_profile" (SUBSTR("birthday", 6, 5))`);
}

async down(queryRunner) {
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/server/api/endpoints/users/following.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
try {
const d = new Date(ps.birthday);
d.setHours(0, 0, 0, 0);
const birthday = `____-${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')}`;
const birthday = `${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')}`;
const birthdayUserQuery = this.userProfilesRepository.createQueryBuilder('user_profile');
birthdayUserQuery.select('user_profile.userId')
.where(`user_profile.birthday LIKE '${birthday}'`);
.where(`SUBSTR(user_profile.birthday, 6, 5) = '${birthday}'`);

query.andWhere(`following.followeeId IN (${ birthdayUserQuery.getQuery() })`);
} catch (err) {
Expand Down

0 comments on commit f79f1a5

Please sign in to comment.