Skip to content

Commit

Permalink
Merge pull request #579 from update-host
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid authored Mar 29, 2024
2 parents 4a52fd1 + 4e1b595 commit 1f209d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "misskey",
"version": "2024.3.1-host.4",
"version": "2024.3.1-host.4a",
"codename": "nasubi",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Inject, Injectable } from '@nestjs/common';
import { Brackets } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type {
FollowingsRepository,
Expand Down Expand Up @@ -90,8 +91,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.innerJoin(this.userProfilesRepository.metadata.targetName, 'followeeProfile', 'followeeProfile.userId = following.followeeId');

if (Object.hasOwn(ps.birthday, 'begin') && Object.hasOwn(ps.birthday, 'end')) {
const { begin, end } = ps.birthday as { begin: { month: number; day: number }; end: { month: number; day: number }; };
query.andWhere('get_birthday_date(followeeProfile.birthday) BETWEEN :begin AND :end', { begin: begin.month * 100 + begin.day, end: end.month * 100 + end.day });
const range = ps.birthday as { begin: { month: number; day: number }; end: { month: number; day: number }; };
const begin = range.begin.month * 100 + range.begin.day;
const end = range.end.month * 100 + range.end.day;

if (begin <= end) {
query.andWhere('get_birthday_date(followeeProfile.birthday) BETWEEN :begin AND :end', { begin, end });
} else {
// 12/31 から 1/1 の範囲を取得するために OR で対応
query.andWhere(new Brackets(qb => {
qb.where('get_birthday_date(followeeProfile.birthday) BETWEEN :begin AND 1231', { begin });
qb.orWhere('get_birthday_date(followeeProfile.birthday) BETWEEN 101 AND :end', { end });
}));
}
} else {
const { month, day } = ps.birthday as { month: number; day: number };
// なぜか get_birthday_date() = :birthday だとインデックスが効かないので、BETWEEN で対応
Expand Down
2 changes: 1 addition & 1 deletion packages/misskey-js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "misskey-js",
"version": "2024.3.1-host.4",
"version": "2024.3.1-host.4a",
"description": "Misskey SDK for JavaScript",
"types": "./built/dts/index.d.ts",
"exports": {
Expand Down

0 comments on commit 1f209d0

Please sign in to comment.