Skip to content

Commit 8fca33f

Browse files
Tony QiuTony Qiu
authored andcommitted
filter for upcoming in grid and calendar
1 parent adc016b commit 8fca33f

File tree

4 files changed

+39
-57
lines changed

4 files changed

+39
-57
lines changed

.github/workflows/instagram_feed.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ jobs:
9595
working-directory: backend/scraping
9696
run: python get_static_events.py
9797

98+
- name: Generate recommended filters
99+
if: github.event_name == 'schedule' || github.event.inputs.run_scraper == 'true'
100+
working-directory: backend/scripts
101+
run: python generate_recommended_filters.py
102+
continue-on-error: true
103+
98104
- name: Send newsletter to subscribers
99105
if: github.event_name == 'schedule' || github.event.inputs.run_scraper == 'true'
100106
working-directory: backend/scripts
@@ -106,6 +112,6 @@ jobs:
106112
run: |
107113
git config --global user.name 'github-actions[bot]'
108114
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
109-
git add frontend/src/data/staticEvents.ts
110-
git commit -m "chore: update static events from DB" || echo "No changes to commit"
115+
git add frontend/src/data/staticEvents.ts frontend/src/data/staticData.ts
116+
git commit -m "chore: update static events and recommended filters from DB" || echo "No changes to commit"
111117
git push

backend/scraping/instagram_feed.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -404,24 +404,5 @@ def session():
404404
logger.info("Session created successfully!")
405405
process_recent_feed(L)
406406

407-
# Generate recommended filters after processing feed
408-
logger.info("Generating recommended filters from upcoming events...")
409-
try:
410-
script_path = Path(__file__).resolve().parent.parent / "scripts" / "generate_recommended_filters.py"
411-
result = subprocess.run(
412-
[sys.executable, str(script_path)],
413-
capture_output=True,
414-
text=True,
415-
timeout=120
416-
)
417-
if result.returncode == 0:
418-
logger.info("✅ Recommended filters generated successfully")
419-
if result.stdout:
420-
logger.info(f"Output: {result.stdout}")
421-
else:
422-
logger.error(f"❌ Failed to generate recommended filters: {result.stderr}")
423-
except Exception as e:
424-
logger.error(f"Error running filter generation script: {e}")
425-
logger.error(f"Traceback: {traceback.format_exc()}")
426407
else:
427408
logger.critical("Failed to initialize Instagram session, stopping...")

frontend/src/hooks/useEvents.ts

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -112,41 +112,36 @@ export function useEvents(view: "grid" | "calendar") {
112112
rawEvents = Array.from(staticEventsData.values());
113113
}
114114

115-
if (view === "grid") {
116-
const now = new Date();
117-
const todayStr =
118-
now.getFullYear() +
119-
"-" +
120-
String(now.getMonth() + 1).padStart(2, "0") +
121-
"-" +
122-
String(now.getDate()).padStart(2, "0");
123-
124-
// Filter for future events and events happening today that haven't finished
125-
return rawEvents.filter((event) => {
126-
const eventDateStr = event.date;
127-
128-
// If event is on a future date, include it
129-
if (eventDateStr > todayStr) {
130-
return true;
131-
}
132-
133-
// If event is today, check if it hasn't finished yet
134-
if (eventDateStr === todayStr) {
135-
const [hours, minutes] = event.end_time.split(":").map(Number);
136-
const eventEndDateTime = new Date();
137-
eventEndDateTime.setHours(hours, minutes, 0, 0);
138-
139-
// Include if event hasn't finished yet (current time < event end time)
140-
return now < eventEndDateTime;
141-
}
142-
143-
return false;
144-
});
145-
}
146-
147-
// For calendar view, return all events (backend already sorted them)
148-
return rawEvents;
149-
}, [hasActiveFilters, data?.event_ids, view]);
115+
const now = new Date();
116+
const todayStr =
117+
now.getFullYear() +
118+
"-" +
119+
String(now.getMonth() + 1).padStart(2, "0") +
120+
"-" +
121+
String(now.getDate()).padStart(2, "0");
122+
123+
// Filter for future events and events happening today that haven't finished
124+
return rawEvents.filter((event) => {
125+
const eventDateStr = event.date;
126+
127+
// If event is on a future date, include it
128+
if (eventDateStr > todayStr) {
129+
return true;
130+
}
131+
132+
// If event is today, check if it hasn't finished yet
133+
if (eventDateStr === todayStr) {
134+
const [hours, minutes] = event.end_time.split(":").map(Number);
135+
const eventEndDateTime = new Date();
136+
eventEndDateTime.setHours(hours, minutes, 0, 0);
137+
138+
// Include if event hasn't finished yet (current time < event end time)
139+
return now < eventEndDateTime;
140+
}
141+
142+
return false;
143+
});
144+
}, [hasActiveFilters, data?.event_ids]);
150145

151146
const previousTitleRef = useRef<string>("Events - Wat2Do");
152147

frontend/src/pages/AboutPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const AboutPage: React.FC = () => {
203203
</h2>
204204
<p className="text-gray-600 dark:text-gray-300 mb-8">
205205
Check Wat2Do regularly for new events. Subscribe to our newsletter for
206-
weekly updates. Don't be afraid to attend events alone! The best
206+
daily updates. Don't be afraid to attend events alone! The best
207207
connections happen when you show up.
208208
</p>
209209

0 commit comments

Comments
 (0)