Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

105 connect button to backend and modify endpoint #112

Merged
merged 13 commits into from
Apr 30, 2024
16 changes: 16 additions & 0 deletions backend/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ def test_endpoint():
"password": doc["password"],
}

@app.route("/scraping")
def test_endpoint():
try:
db = client["test"]
collection = db["users"]
doc = collection.find_one()

if doc is not None:
return {
"id": str(doc["_id"]),
"email": doc["email"],
"password": doc["password"],
}
return {"status": "success", "message": "Data scraped successfully"}
except Exception as e:
return {"status": "error", "message": str(e)}

# dummy post method
@app.route("/users", methods=["POST"])
Expand Down
50 changes: 27 additions & 23 deletions backend/api/chalicelib/routes/slo_county.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,35 @@ def hello_world():

@slo_county_blueprint.route("/slo_county/hearings", cors=True)
def get_hearings():
hearings = scrape_hearings()
projects = []
for hearing in hearings:
# scrape projects from each hearing
hearing_projects = scrape_agenda(hearing["link"])
for project in hearing_projects:
# create a Project object for each project
projects.append(
Project(
county_file_number=project["county_file_number"],
hearing_date=hearing["date"],
review_status=None,
location="San Luis Obispo",
apn=project["assessor_parcel_number"],
date_accepted=project["date_accepted"],
requesting_party=project["requesting_party"],
sch_number=None,
title=None,
public_hearing_agenda_link=hearing["link"],
sch_page_link=None,
additional_notes=None,
try:
hearings = scrape_hearings()
projects = []
for hearing in hearings:
# scrape projects from each hearing
hearing_projects = scrape_agenda(hearing["link"])
for project in hearing_projects:
# create a Project object for each project
projects.append(
Project(
county_file_number=project["county_file_number"],
hearing_date=hearing["date"],
review_status=None,
location="San Luis Obispo",
apn=project["assessor_parcel_number"],
date_accepted=project["date_accepted"],
requesting_party=project["requesting_party"],
sch_number=None,
title=None,
public_hearing_agenda_link=hearing["link"],
sch_page_link=None,
additional_notes=None,
)
)
)

add_projects_to_mongo(projects)
add_projects_to_mongo(projects)
return {"status": "success", "message": "OK"}, 200
except Exception as e:
return {"status": "error", "message": f"Failed to process data: {str(e)}"}, 500

# sch_projects = scrape_sch()
# To do: cross-reference projects in sch and fill in missing data
Expand Down
209 changes: 207 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5",
"@tanstack/react-table": "^8.13.2",
"axios": "^1.6.5",
"class-variance-authority": "^0.7.0",
Expand All @@ -25,9 +26,11 @@
"mongoose": "^7.6.3",
"next": "^14.1.1",
"next-auth": "^4.24.5",
"notistack": "^3.0.1",
"react": "^18",
"react-dom": "^18",
"react-icons": "^5.0.1",
"react-toastify": "^10.0.5",
"tailwind-merge": "^2.2.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.22.4"
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Navbar from "@/components/navbar";
import Footer from "@/components/footer";
import { Inter as FontSans } from "next/font/google";
import "@/styles/globals.css";
import { Toaster } from "@/components/ui/toaster";

import { cn } from "@/lib/utils";
import AuthProvider from "@/Providers";
Expand Down Expand Up @@ -34,6 +35,7 @@ export default function RootLayout({
<AuthProvider>
<Navbar />
<div className="flex-1 px-20 py-5">{children}</div>
<Toaster />
<Footer />
</AuthProvider>
</body>
Expand Down
Loading
Loading