Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cca508c
chore: migrate freerooms deployment to devsoc-unsw org (#631)
mt-fns Jun 19, 2025
75f2803
648 refactor ratings logic (#649)
mt-fns Sep 10, 2025
4b2ba49
Revert "648 refactor ratings logic (#649)" (#650)
mt-fns Sep 12, 2025
cb657a6
648 refactor ratings logic (#652)
mt-fns Sep 29, 2025
87582c8
update frontend dockerfile to include env variable (#659)
mt-fns Oct 3, 2025
3e29e74
Add missing env variables for staging (#660)
mt-fns Oct 3, 2025
50dcb37
chore(deps): bump form-data from 3.0.2 to 3.0.4 in /app (#636)
dependabot[bot] Oct 5, 2025
52c9b61
chore(deps): bump form-data from 4.0.2 to 4.0.4 in /frontend (#657)
dependabot[bot] Oct 5, 2025
344a706
chore(deps): update dependency axios to v1.12.0 [security] (#655)
renovate[bot] Oct 5, 2025
5bfeccf
add K-C29 building image (#662)
mt-fns Oct 28, 2025
905574b
chore: migrate freerooms deployment to devsoc-unsw org (#631) (#664)
mt-fns Oct 28, 2025
07a85c7
merge master into dev
mt-fns Oct 28, 2025
df8b92b
2025-backend-refactor (#663)
mt-fns Oct 28, 2025
447e926
remove copy .env command in fronted dockerfile (#665)
mt-fns Oct 28, 2025
663066e
Fix Frontend Dockerfile (#666)
mt-fns Oct 28, 2025
4d1c3fb
Merge branch 'master' of https://github.com/devsoc-unsw/freerooms int…
mt-fns Oct 29, 2025
7fba1be
remove frontend.env copy in dockerfile
mt-fns Oct 29, 2025
bccc485
2025 UI Redesign (#653)
c0nnied Nov 11, 2025
e847de9
661 feature all rooms card redesign (#668)
c0nnied Nov 14, 2025
298f999
chore(deps): bump js-yaml in /app
dependabot[bot] Nov 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
env:
ENVIRONMENT: ${{ github.ref_name == 'master' && 'prod' || 'staging' }}
IMAGE_NAME: ${{ github.ref_name == 'master' && 'freerooms' || 'freerooms-staging' }}
BRANCH_NAME: ${{ github.base_ref || github.ref_name }}

jobs:
build:
Expand Down Expand Up @@ -55,6 +56,8 @@ jobs:
ghcr.io/devsoc-unsw/${{ env.IMAGE_NAME }}-${{ matrix.name }}:${{ github.sha }}
ghcr.io/devsoc-unsw/${{ env.IMAGE_NAME }}-${{ matrix.name }}:latest
labels: ${{ steps.meta.outputs.labels }}
build-args: |
${{ env.BRANCH_NAME == 'dev' && matrix.context == 'frontend' && 'NEXT_PUBLIC_STAGING=true' || '' }}
deploy:
name: Deploy (CD)
runs-on: ubuntu-latest
Expand Down
2 changes: 0 additions & 2 deletions app/components/RoomCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ const RoomCard: React.FC<RoomCardProps> = ({
nav.navigate("Room", { roomName, roomId, status });
};

// console.log(roomName);

const date = new Date(status.endtime);
const hoursMinutes = date.toLocaleTimeString("en-AU", {
hour: "numeric",
Expand Down
132 changes: 93 additions & 39 deletions app/package-lock.json

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

41 changes: 36 additions & 5 deletions backend/src/ratingDbInterface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {
AverageRating,
BuildingRatingsResponse,
Rating,
RatingsResponse,
RawRatingDocument,
} from "@common/types";
import dotenv from "dotenv";
import { Collection, MongoClient } from "mongodb";
Expand Down Expand Up @@ -102,13 +104,19 @@ export async function insertBuldingRating(
}
}

export async function getRatings(roomId: string): Promise<Rating[]> {
export async function getRatings(roomId: string): Promise<RatingsResponse> {
if (!MONGO_URI) {
throw new Error("MONGO_URI not found");
}

const client = new MongoClient(MONGO_URI);

const averagedRatings: AverageRating = {
cleanliness: 0,
location: 0,
quietness: 0,
};

try {
await client.connect();
const database = client.db("room-ratings");
Expand All @@ -124,16 +132,39 @@ export async function getRatings(roomId: string): Promise<Rating[]> {

// Document found, return ratings array
if (roomDoc !== null) {
const roomRating = roomDoc as unknown as RatingsResponse;
return roomRating.ratings;
const foundDoc = roomDoc as unknown as RawRatingDocument;
let averagedOverallRating = 0;

foundDoc.ratings.map((doc: Rating) => {
averagedRatings.cleanliness += doc.cleanliness;
averagedRatings.location += doc.location;
averagedRatings.quietness += doc.quietness;
averagedOverallRating += doc.overall;
});

const numFound = foundDoc.ratings.length;
if (foundDoc.ratings.length > 0) {
averagedRatings.cleanliness /= numFound;
averagedRatings.location /= numFound;
averagedRatings.quietness /= numFound;
averagedOverallRating /= numFound;
}

const res = {
roomId: foundDoc.roomId,
overallRating: averagedOverallRating,
averageRating: averagedRatings,
};

return res;
}
} catch (error) {
console.error("Error finding item:", error);
} finally {
await client.close();
}
// No document found, return empty array
return [];
// No document found, return empty object
return { roomId: roomId, overallRating: 0, averageRating: averagedRatings };
}

export async function getBuildingRatings(
Expand Down
16 changes: 15 additions & 1 deletion common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export type Rating = {
overall: number;
};

export type AverageRating = {
cleanliness: number;
location: number;
quietness: number;
}

///////////////////////////////////////////////////////////////
// API Response Types

Expand Down Expand Up @@ -80,10 +86,18 @@ export type BookingsResponse = {
bookings: Booking[];
};


// how ratings are stored in Mongo
export type RawRatingDocument = {
roomId: string,
ratings: Rating[]
}

export type RatingsResponse = {
// roomId refers to room name
roomId: string;
ratings: Rating[];
overallRating: number;
averageRating: AverageRating;
};

export type BuildingRatingsResponse = {
Expand Down
6 changes: 6 additions & 0 deletions frontend.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ RUN npm ci
# Rebuild the source code only when needed
FROM node:22-alpine AS builder

# Accept build args for environment variables
ARG NEXT_PUBLIC_STAGING=false

WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY /frontend .
COPY common ../common

# Set the environment variable for Next.js build
ENV NEXT_PUBLIC_STAGING=$NEXT_PUBLIC_STAGING

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
Expand Down
Loading