Skip to content

Commit

Permalink
next step
Browse files Browse the repository at this point in the history
  • Loading branch information
Alder Whiteford authored and Alder Whiteford committed Jun 14, 2024
1 parent 4ee5e27 commit a4bc462
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 41 deletions.
2 changes: 1 addition & 1 deletion frontend/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@generatesac/lib",
"version": "0.0.168",
"version": "0.0.169",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions frontend/lib/src/types/club.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "zod";

import { rootModelSchema } from "./root";
import { recruitmentSchema } from "./recruitment";

// Schemas:
export const createClubRequestBodySchema = z.object({
Expand Down Expand Up @@ -35,11 +36,10 @@ const clubSchemaIntermediate = z.object({
preview: z.string().max(255),
description: z.string(),
num_members: z.number(),
is_recruiting: z.boolean(),
application_link: z.string().max(255),
logo: z.string().max(255).optional(),
weekly_time_committment: z.number().optional(),
one_word_to_describe_us: z.string().max(20).optional(),
recruitment: recruitmentSchema.optional(),
});

export const clubSchema = clubSchemaIntermediate.merge(rootModelSchema);
Expand Down
2 changes: 1 addition & 1 deletion frontend/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@fortawesome/free-solid-svg-icons": "^6.5.2",
"@fortawesome/react-fontawesome": "^0.2.2",
"@fortawesome/react-native-fontawesome": "^0.3.2",
"@generatesac/lib": "0.0.168",
"@generatesac/lib": "0.0.169",
"@gorhom/bottom-sheet": "^4.6.3",
"@hookform/resolvers": "^3.4.2",
"@react-native-async-storage/async-storage": "^1.23.1",
Expand Down
35 changes: 25 additions & 10 deletions frontend/mobile/src/app/(app)/event/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const EventPage = () => {

const [getEvent, { isLoading: eventLoading, error: eventError, data: event }] = eventApi.useLazyEventQuery();

Check failure on line 61 in frontend/mobile/src/app/(app)/event/[id].tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `getEvent,·{·isLoading:·eventLoading,·error:·eventError,·data:·event·}` with `⏎········getEvent,⏎········{·isLoading:·eventLoading,·error:·eventError,·data:·event·}⏎····`
const [getClub, { isLoading: clubLoading, error: clubError, data: club }] = clubApi.useLazyClubQuery();

Check failure on line 62 in frontend/mobile/src/app/(app)/event/[id].tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `⏎·······`
const [getEventTags, { isLoading: tagsLoading, error: tagsError, data: tags }] = eventApi.useLazyEventTagsQuery();

Check failure on line 63 in frontend/mobile/src/app/(app)/event/[id].tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `getEventTags,·{·isLoading:·tagsLoading,·error:·tagsError,·data:·tags·}` with `⏎········getEventTags,⏎········{·isLoading:·tagsLoading,·error:·tagsError,·data:·tags·}⏎····`

Check warning on line 63 in frontend/mobile/src/app/(app)/event/[id].tsx

View workflow job for this annotation

GitHub Actions / Lint

'tags' is already declared in the upper scope on line 17 column 31

const imageAnimatedStyle = useAnimatedStyle(() => {
return {
Expand Down Expand Up @@ -97,14 +98,28 @@ const EventPage = () => {
});

useEffect(() => {
// Fetch events
getEvent(id as string)

Check failure on line 102 in frontend/mobile/src/app/(app)/event/[id].tsx

View workflow job for this annotation

GitHub Actions / Lint

Delete `⏎············`
.then((data) => {
if (!error) {
console.log(data);
.then(({ data: eventData }) => {
if (eventData) {

Check failure on line 104 in frontend/mobile/src/app/(app)/event/[id].tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `················` with `············`
// Fetch club

Check failure on line 105 in frontend/mobile/src/app/(app)/event/[id].tsx

View workflow job for this annotation

GitHub Actions / Lint

Delete `····`
getClub(eventData.host as string)
.then(({ data: clubData }) => {
console.log(clubData);
});
// Fetch tags:
getEventTags(eventData.id)
.then(({ data: tagsData }) => {
console.log(tagsData);
});
}
})
}, [retriggerFetch]);

const apiLoading = eventLoading || clubLoading || tagsLoading;
const apiError = eventError || clubError || tagsError;
const allData = event && tags && club

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (94% of all statements in
the enclosing function
have an explicit semicolon).

return (
<Box backgroundColor="white" height={'100%'}>
<Stack.Screen
Expand All @@ -117,10 +132,10 @@ const EventPage = () => {
},
headerLeft: () => (

Check warning on line 133 in frontend/mobile/src/app/(app)/event/[id].tsx

View workflow job for this annotation

GitHub Actions / Lint

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “EventPage” and pass data as props. If you want to allow component creation in props, set allowAsProps option to true
<Animated.View style={headerAnimatedStyle}>
<Arrow color={error ? 'black' : "white"} />
<Arrow color={eventError || clubError ? 'black' : "white"} />
</Animated.View>
),
headerRight: !error ? () => (
headerRight: !eventError || clubError ? () => (

Check warning on line 138 in frontend/mobile/src/app/(app)/event/[id].tsx

View workflow job for this annotation

GitHub Actions / Lint

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “EventPage” and pass data as props. If you want to allow component creation in props, set allowAsProps option to true
<Animated.View style={headerAnimatedStyle}>
<KebabMenu
onPress={() =>
Expand All @@ -137,11 +152,11 @@ const EventPage = () => {
scrollEventThrottle={16}
ref={scrollRef}
>
{eventLoading || clubLoading
{apiLoading
? <EventPageSkeleton />
: eventError || clubError
: apiError
? <EventPageError refetch={setRetriggerFetch}/>
: event && club && <>
: allData && <>
<Box>
<Animated.Image
source={{
Expand All @@ -161,7 +176,7 @@ const EventPage = () => {
logo={MockEvent.logo}
eventName={event.name}
color={MockEvent.color}
club={event.host}
club={club?.name}
startTime={new Date(event.start_time)}
endTime={new Date(event.end_time)}
location={event.location}
Expand All @@ -179,7 +194,7 @@ const EventPage = () => {
color={MockEvent.color}
zoomLink={event.link}
description={event.description}
tags={MockEvent.tags}
tags={tags}
onPress={() => bottomSheet.current?.snapToIndex(0)}
/>
<Location location={event.location} />
Expand Down
8 changes: 4 additions & 4 deletions frontend/mobile/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1402,10 +1402,10 @@
humps "^2.0.1"
prop-types "^15.7.2"

"@generatesac/[email protected].168":
version "0.0.168"
resolved "https://registry.yarnpkg.com/@generatesac/lib/-/lib-0.0.168.tgz#655c1daac6008b1ced1f259cc10f20afc85d6cba"
integrity sha512-lSvFdUYa2j/UjlzQSpE4EUpjLUD2Y3cIOmM88x4X2eVNeh25IHGUXZSxYdX7tNH/RMj7Rr5PQYix/VE8qxZ//A==
"@generatesac/[email protected].169":
version "0.0.169"
resolved "https://registry.yarnpkg.com/@generatesac/lib/-/lib-0.0.169.tgz#6a5799bad43b7c08553a04e5e6ed401ed0b7e7ab"
integrity sha512-IeWdlMKTi9zdqeaSMWWB+fjma6zf3Z1lO7mPmQ8Q+PJ49CkjJVbF5G9tdYgnJrNSz9+fazr5kFXZZl26eJaN0w==
dependencies:
"@reduxjs/toolkit" "^2.2.3"
react "^18.2.0"
Expand Down
3 changes: 3 additions & 0 deletions mock_data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/bin
/lib
*.cfg
79 changes: 56 additions & 23 deletions mock_data/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,55 +26,55 @@
PARENT_UUID = args.parent_uuid

MOCK_CATEGORIES_AND_TAGS = {
"PreProfessional": [
"Pre-Professional": [
"Premed",
"Prelaw",
],
"CulturalAndIdentity": [
"Cultural And Identity": [
"Judaism",
"Christianity",
"Hinduism",
"Islam",
"LatinAmerica",
"AfricanAmerican",
"AsianAmerican",
"Latin America",
"African American",
"Asian American",
"LGBTQ",
],
"ArtsAndCreativity": [
"PerformingArts",
"VisualArts",
"CreativeWriting",
"Arts And Creativity": [
"Performing Arts",
"Visual Arts",
"Creative Writing",
"Music",
],
"SportsAndRecreation": [
"Sports And Recreation": [
"Soccer",
"Hiking",
"Climbing",
"Lacrosse",
],
"ScienceAndTechnology": [
"Science And Technology": [
"Mathematics",
"Physics",
"Biology",
"Chemistry",
"EnvironmentalScience",
"Environmental Science",
"Geology",
"Neuroscience",
"Psychology",
"SoftwareEngineering",
"ArtificialIntelligence",
"DataScience",
"MechanicalEngineering",
"ElectricalEngineering",
"IndustrialEngineering",
"Software Engineering",
"Artificial Intelligence",
"Data Science",
"Mechanical Engineering",
"Electrical Engineering",
"Industrial Engineering",
],
"CommunityServiceAndAdvocacy": [
"Community Service And Advocacy": [
"Volunteerism",
"EnvironmentalAdvocacy",
"Environmental Advocacy",
"HumanRights",
"CommunityOutreach",
"Community Outreach",
],
"MediaAndCommunication": [
"Media And Communication": [
"Journalism",
"Broadcasting",
"Film",
Expand Down Expand Up @@ -129,13 +129,15 @@ def random_start_and_endtimes() -> tuple[datetime.datetime, datetime.datetime]:
print("NUEngage request done.")

clubs_json = json.loads(clubs_response.text)['value']
print(clubs_json)
clubs = []
events = []

bar = Bar('Making club data', max=len(clubs_json), suffix="%(remaining)d Remaining, ETA: %(eta_td)s")
bad_club_descriptions = 0
for club in clubs_json:
name = club['Name'].replace("(Tentative) ", "").replace("( Tentative) ", "")
logo = "https://se-images.campuslabs.com/clink/images/{}".format(club['ProfilePicture'])
preview = club['Summary'][:250]
description = club['Description']

Expand All @@ -150,6 +152,8 @@ def random_start_and_endtimes() -> tuple[datetime.datetime, datetime.datetime]:
]
)

print('Created description for club:', name)

description = json.loads(description_response.choices[0].message.content)['description']
# Some description responses will not contain valid JSON, hence this if check.
if not isinstance(description, str):
Expand All @@ -168,6 +172,10 @@ def random_start_and_endtimes() -> tuple[datetime.datetime, datetime.datetime]:
)

tags = json.loads(tags_response.choices[0].message.content)['tags']

logoOptions = [

]

clubData = {
"id": str(uuid4()),
Expand Down Expand Up @@ -200,19 +208,44 @@ def random_start_and_endtimes() -> tuple[datetime.datetime, datetime.datetime]:
event_description = "Event description"

times = random_start_and_endtimes()

event_type = random.choice(["hybrid", "in_person", "virtual"])
link = ""
if event_type == "hybrid" or event_type == "virtual":
link = "https://northeastern.zoom.us/j/6610103275"

location = random.choice(["West Village H", "Curry Student Center", "Snell Library", "Krentzman Quad", "Marino", "ISEC", "ISEC 2"])
if event_type == "online":
location = ""

events.append({
"id": str(uuid4()),
"club_id": clubData["id"],
"name": f"Event for {clubData["name"]}",
"preview": "This club is holding an event.",
"description": event_description,
"event_type": random.choice(["hybrid", "in_person", "virtual"]),
"event_type": event_type,
"start_time": times[0].strftime("%Y-%m-%d %H:%M:%S"),
"end_time": times[1].strftime("%Y-%m-%d %H:%M:%S"),
"link": link,
"location": location,
"tags": random.sample(tags, random.randint(1,len(tags)))
})
bar.next()

# name: z.string().max(255),
# preview: z.string().max(255),
# description: z.string(),
# start_time: z.string(),
# end_time: z.string(),
# location: z.string().max(255),
# link: z.string().max(255).optional(),
# event_type: eventTypeEnum,
# is_recurring: z.boolean().optional(),
# is_public: z.boolean(),
# is_draft: z.boolean(),
# is_archived: z.boolean(),
# host: z.string().uuid(),

bar.finish()
print(f"Bad club descriptions (JSON not created properly): {bad_club_descriptions}")
Expand Down

0 comments on commit a4bc462

Please sign in to comment.