MCPcopy Create free account
hub / github.com/SuperteamDAO/earn / buildHackathonQuery

Function buildHackathonQuery

src/features/hackathon/utils/query-builder.ts:71–149  ·  view source on GitHub ↗
(
  args: BuildHackathonQueryArgs,
  user: {
    id: string;
    isTalentFilled: boolean;
    location: string | null;
    skills: JsonValue;
  } | null,
)

Source from the content-addressed store, hash-verified

69}
70
71export async function buildHackathonQuery(
72 args: BuildHackathonQueryArgs,
73 user: {
74 id: string;
75 isTalentFilled: boolean;
76 location: string | null;
77 skills: JsonValue;
78 } | null,
79): Promise<HackathonQueryResult> {
80 const { name, status, context } = args;
81
82 const where: BountiesWhereInput = {
83 isPublished: true,
84 isActive: true,
85 isArchived: false,
86 isPrivate: false,
87 type: 'hackathon',
88 };
89
90 const allHackathonNames = HackathonSchema._def.innerType.options.filter(
91 (option: string) => option !== 'All',
92 );
93
94 if (name === 'All') {
95 where.Hackathon = { name: { in: allHackathonNames } };
96 } else if (allHackathonNames.includes(name)) {
97 where.Hackathon = { name: name };
98 }
99
100 const andConditions: BountiesWhereInput[] = [];
101
102 if (context === 'home') {
103 andConditions.push({
104 language: { in: ['eng', 'sco'] },
105 OR: [
106 { compensationType: 'fixed', usdValue: { gt: 100 } },
107 { compensationType: 'range', maxRewardAsk: { gt: 100 } },
108 { compensationType: 'variable' },
109 ],
110 });
111 }
112
113 if (user?.isTalentFilled && (context === 'all' || context === 'home')) {
114 const chapterRegions = await getChapterRegions();
115 const userRegion = user?.location
116 ? getCombinedRegion(user?.location, true, chapterRegions)
117 : undefined;
118
119 where.region = {
120 in: userRegion?.name
121 ? [
122 'Global',
123 userRegion.name,
124 ...(filterRegionCountry(userRegion, user.location || '').country ||
125 []),
126 ...(getParentRegions(userRegion) || []),
127 ]
128 : ['Global'],

Callers 1

GETFunction · 0.90

Calls 6

getChapterRegionsFunction · 0.90
getCombinedRegionFunction · 0.90
filterRegionCountryFunction · 0.90
getParentRegionsFunction · 0.90
getOrderByFunction · 0.70

Tested by

no test coverage detected