Skip to content

Commit

Permalink
Merge pull request #210 from h8570rg/develop
Browse files Browse the repository at this point in the history
Prd
  • Loading branch information
h8570rg authored Dec 22, 2024
2 parents f100e2d + 8cc7c4d commit d3bb723
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { NextUIProvider } from "./nextUiProvider";

export const metadata: Metadata = {
title: {
template: "%s | Janreco",
default: "Janreco",
template: "%s | 雀鬼録",
default: "雀鬼録",
},
description:
"麻雀成績管理ウェブアプリです。無料で使え、簡単に麻雀の成績を記録することができます。",
Expand Down
9 changes: 9 additions & 0 deletions lib/database.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,20 @@ export type Database = {
};
profiles: {
Row: {
display_id: string | null;
id: string;
janreco_id: string | null;
name: string | null;
name_janreco_id: string | null;
};
Insert: {
display_id?: string | null;
id?: string;
janreco_id?: string | null;
name?: string | null;
};
Update: {
display_id?: string | null;
id?: string;
janreco_id?: string | null;
name?: string | null;
Expand Down Expand Up @@ -383,6 +386,7 @@ export type Database = {
owner_id: string | null;
path_tokens: string[] | null;
updated_at: string | null;
user_metadata: Json | null;
version: string | null;
};
Insert: {
Expand All @@ -396,6 +400,7 @@ export type Database = {
owner_id?: string | null;
path_tokens?: string[] | null;
updated_at?: string | null;
user_metadata?: Json | null;
version?: string | null;
};
Update: {
Expand All @@ -409,6 +414,7 @@ export type Database = {
owner_id?: string | null;
path_tokens?: string[] | null;
updated_at?: string | null;
user_metadata?: Json | null;
version?: string | null;
};
Relationships: [
Expand All @@ -430,6 +436,7 @@ export type Database = {
key: string;
owner_id: string | null;
upload_signature: string;
user_metadata: Json | null;
version: string;
};
Insert: {
Expand All @@ -440,6 +447,7 @@ export type Database = {
key: string;
owner_id?: string | null;
upload_signature: string;
user_metadata?: Json | null;
version: string;
};
Update: {
Expand All @@ -450,6 +458,7 @@ export type Database = {
key?: string;
owner_id?: string | null;
upload_signature?: string;
user_metadata?: Json | null;
version?: string;
};
Relationships: [
Expand Down
2 changes: 1 addition & 1 deletion lib/services/features/friend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function friendService(supabase: Supabase) {
return friends.map((friend) => ({
id: friend.profiles.id,
name: friend.profiles.name,
janrecoId: friend.profiles.janreco_id,
janrecoId: friend.profiles.display_id,
}));
},

Expand Down
4 changes: 2 additions & 2 deletions lib/services/features/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function formatMatch(match: {
profiles: {
id: string;
name: string | null;
janreco_id: string | null;
display_id: string | null;
};
chip_count: number | null;
}[];
Expand Down Expand Up @@ -216,7 +216,7 @@ function formatMatch(match: {
({ profiles, chip_count }) => ({
id: profiles.id,
name: profiles.name,
janrecoId: profiles.janreco_id,
janrecoId: profiles.display_id,
rankCounts: new Array(rule.players_count).fill(0),
averageRank: null,
totalScore: 0,
Expand Down
18 changes: 9 additions & 9 deletions lib/services/features/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export function profileService(supabase: Supabase) {
return {
id: userProfile.id,
name: userProfile.name,
janrecoId: userProfile.janreco_id,
janrecoId: userProfile.display_id,
isUnregistered:
userProfile.name === null || userProfile.janreco_id === null,
userProfile.name === null || userProfile.display_id === null,
isAnonymous: !!user.is_anonymous,
};
},
Expand All @@ -65,7 +65,7 @@ export function profileService(supabase: Supabase) {

const updatedUserProfileResponse = await supabase
.from("profiles")
.update({ name, janreco_id: janrecoId })
.update({ name, display_id: janrecoId })
.eq("id", user.id)
.select()
.single();
Expand All @@ -78,10 +78,10 @@ export function profileService(supabase: Supabase) {
data: {
id: updatedUserProfile.id,
name: updatedUserProfile.name,
janrecoId: updatedUserProfile.janreco_id,
janrecoId: updatedUserProfile.display_id,
isUnregistered:
updatedUserProfile.name === null ||
updatedUserProfile.janreco_id === null,
updatedUserProfile.display_id === null,
isAnonymous: !!user.is_anonymous,
},
};
Expand All @@ -102,8 +102,8 @@ export function profileService(supabase: Supabase) {
supabase
.from("profiles")
.select("*")
.or(`name.ilike.%${text}%,janreco_id.ilike.%${text}%`)
.neq("janreco_id", null)
.or(`name.ilike.%${text}%,display_id.ilike.%${text}%`)
.neq("display_id", null)
.neq("name", null)
.neq("id", user.id),
supabase.from("friends").select("friend_id").eq("profile_id", user.id),
Expand All @@ -117,7 +117,7 @@ export function profileService(supabase: Supabase) {
return profiles.map((profile) => ({
id: profile.id,
name: profile.name!,
janrecoId: profile.janreco_id!,
janrecoId: profile.display_id!,
isFriend: friends.some((friend) => friend.friend_id === profile.id),
}));
},
Expand All @@ -134,7 +134,7 @@ export function profileService(supabase: Supabase) {
return {
id: profile.id,
name: profile.name ?? name,
janrecoId: profile.janreco_id,
janrecoId: profile.display_id,
};
},
};
Expand Down
7 changes: 7 additions & 0 deletions supabase/migrations/20241222083712_local.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
alter table "public"."profiles" add column "display_id" text;

CREATE UNIQUE INDEX profiles_display_id_key ON public.profiles USING btree (display_id);

alter table "public"."profiles" add constraint "profiles_display_id_key" UNIQUE using index "profiles_display_id_key";


0 comments on commit d3bb723

Please sign in to comment.