Skip to content

Commit

Permalink
Merge branch 'main' of github.com:noverney/randoms
Browse files Browse the repository at this point in the history
  • Loading branch information
Normand Overney committed Oct 29, 2023
2 parents 946c555 + b443e22 commit d402b81
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 239 deletions.
4 changes: 2 additions & 2 deletions frontend/pages/index.vue
Expand Up @@ -6,7 +6,7 @@
class="relative overflow-hidden bg-gray-900 px-6 py-20 shadow-xl sm:rounded-3xl sm:px-10 sm:py-24 md:px-12 lg:px-20">
<div class="absolute inset-0 bg-gray-900/90 mix-blend-multiply" />
<div class="absolute -left-80 -top-56 transform-gpu blur-3xl" aria-hidden="true">
<div class="aspect-[1097/845] w-[68.5625rem] bg-gradient-to-r from-[#ff4694] to-[#776fff] opacity-[0.45]"
<div class="aspect-[1097/845] w-[68.5625rem] bg-gradient-to-r from-[#ff4694] to-[#009EE3] opacity-[0.45]"
style="
clip-path: polygon(
74.1% 44.1%,
Expand All @@ -30,7 +30,7 @@
</div>
<div class="hidden md:absolute md:bottom-16 md:left-[50rem] md:block md:transform-gpu md:blur-3xl"
aria-hidden="true">
<div class="aspect-[1097/845] w-[68.5625rem] bg-gradient-to-r from-[#ff4694] to-[#776fff] opacity-25" style="
<div class="aspect-[1097/845] w-[68.5625rem] bg-gradient-to-r from-[#ff4694] to-[#009EE3] opacity-25" style="
clip-path: polygon(
74.1% 44.1%,
100% 61.6%,
Expand Down
32 changes: 17 additions & 15 deletions frontend/pages/login.vue
Expand Up @@ -4,7 +4,7 @@
<div class="flex flex-1 flex-col justify-center px-4 py-12 sm:px-6 lg:flex-none lg:px-20 xl:px-24">
<div class="mx-auto w-full max-w-sm lg:w-96">
<div>
<img class="h-10 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600"
<img class="h-10 w-auto" src="/justlogo.svg"
alt="Your Company" />
<h2 class="mt-8 text-2xl font-bold leading-9 tracking-tight text-gray-900">Sign in to your account
</h2>
Expand All @@ -13,22 +13,24 @@
<div class="mt-10">
<div>
<form @submit.prevent="signInWithPassword" class="space-y-6">
<div>
<label for="email" class="block text-sm font-medium leading-6 text-gray-900">Email
address</label>
<div class="mt-2">
<UInput v-model="email" id="email" name="email" type="email" autocomplete="email"
required />
</div>
<div class="relative">
<UInput v-model="email" id="email" name="email" type="text"
class="peer h-10 w-full border-b-2 border-gray-300 text-gray-900 placeholder-transparent focus:outline-none focus:border-sky-600"
variant="none" placeholder="john@endress.com" />
<label for="email"
class="absolute left-0 -top-3.5 text-gray-600 text-sm transition-all peer-placeholder-shown:text-base peer-placeholder-shown:text-gray-400 peer-placeholder-shown:top-2 peer-focus:-top-3.5 peer-focus:text-gray-600 peer-focus:text-sm">
Email address
</label>
</div>

<div>

<div class="mt-5 relative">
<UInput v-model="password" id="password" name="password" type="password"
class="peer h-10 w-full border-b-2 border-gray-300 text-gray-900 placeholder-transparent focus:outline-none focus:border-sky-600"
variant="none" placeholder="password" />
<label for="password"
class="block text-sm font-medium leading-6 text-gray-900">Password</label>
<div class="mt-2">
<UInput v-model="password" id="password" name="password" type="password"
autocomplete="current-password" required />
</div>
class="absolute left-0 -top-3.5 text-gray-600 text-sm transition-all peer-placeholder-shown:text-base peer-placeholder-shown:text-gray-400 peer-placeholder-shown:top-2 peer-focus:-top-3.5 peer-focus:text-gray-600 peer-focus:text-sm">
Password
</label>
</div>

<div>
Expand Down
6 changes: 6 additions & 0 deletions frontend/pages/user.vue
Expand Up @@ -99,6 +99,8 @@ watch(extendedUserInformation, () => {
}
})
const toast = useToast()
const department = ref('')
const funfact = ref('')
const userInterests = ref<UserInterests>({})
Expand Down Expand Up @@ -136,5 +138,9 @@ const saveChanges = async () => {
team: department.value,
days: selectedDays.value
});
toast.add({title: 'Informations Saved!', icon: 'i-heroicons-check-circle'})
navigateTo('/')
};
</script>
1 change: 1 addition & 0 deletions frontend/public/justlogo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions functions/main.py
Expand Up @@ -5,6 +5,7 @@
from firebase_functions import https_fn
from firebase_admin import initialize_app
from firebase_admin import firestore
from firebase_admin import auth
from datetime import date
from data import User, Match
from notification import notify_user_about_match, POSTMARK_API_KEY
Expand All @@ -14,12 +15,20 @@

default_app = initialize_app()

def user_exists(uid: str):
try:
auth.get_user(uid)
return True
except:
print("User with ID " + uid + " does not exist")
return False

def get_all_users():
db = firestore.client()
docs = (
db.collection("users")
.stream())
return [ User(doc.id, doc.to_dict()) for doc in docs ]
return [ User(doc.id, doc.to_dict()) for doc in docs if user_exists(doc.id) ]

def match_users(users: list[User]):
# this is the entrypoint for your matching code
Expand Down Expand Up @@ -59,7 +68,7 @@ def trigger_matching(req: https_fn.Request) -> https_fn.Response:
"id": match.user2.id,
"name": match.user2.name,
"email": match.user2.email,
"avatarUrl": match.user1.avatarUrl or f"https://source.boringavatars.com/beam/120/{match.user2.id}?colors=264653,2a9d8f,e9c46a,f4a261,e76f51"
"avatarUrl": match.user2.avatarUrl or f"https://source.boringavatars.com/beam/120/{match.user2.id}?colors=264653,2a9d8f,e9c46a,f4a261,e76f51"
}
],
"date": match.date.isoformat()
Expand All @@ -78,3 +87,5 @@ def add_fake_users(req: https_fn.Request) -> https_fn.Response:
print("Adding fake users")
add_fake_firestore_users(4)
return https_fn.Response("Added 10 fake users")


14 changes: 13 additions & 1 deletion functions/matching_users.py
Expand Up @@ -5,7 +5,7 @@
import numpy as np
from sklearn.metrics.pairwise import cosine_similarity
import collections
from functions.data import User
from data import User

def get_sorted_list_func(user_ids, user_preferences):
def get_sorted_list(user_index):
Expand All @@ -21,10 +21,22 @@ def check_input(user_ids, preference_matrix):
if len(user_ids) != len(preference_matrix):
raise ValueError(f"user list and matrix length do not match")

def add_noise_to_array(arr, noise_factor):
if not 0 <= noise_factor <= 1:
raise ValueError("Noise factor should be between 0 and 1")
elif noise_factor == 0:
return arr
noise = np.random.uniform(0, noise_factor, arr.shape)
noisy_array = arr + noise
noisy_array = np.clip(noisy_array, 0, 1)
return noisy_array

def get_preference_lists(user_ids, preference_matrix):
check_input(user_ids, preference_matrix)

user_preferences = cosine_similarity(preference_matrix)
user_preferences = add_noise_to_array(user_preferences, 0) # ADJUST NOISE HERE

get_sorted_list = get_sorted_list_func(user_ids, user_preferences)
return [get_sorted_list(user_index) for user_index in range(len(user_ids))]

Expand Down
6 changes: 3 additions & 3 deletions functions/notification.py
Expand Up @@ -23,14 +23,14 @@ def send_email_to_user(user: User, matchedWith: User):
else:
postmark = PostmarkClient(server_token=POSTMARK_API_KEY.value)
postmark.emails.send_with_template(
From='alex@rovner.ch',
From='noreply@meetingmunch.com',
To=user_email,
TemplateId="33637852",
TemplateModel={
"name": user.name,
"action_url": "https://baselhack2023-randoms.web.app/",
"action_url": "https://meetingmunch.com/",
"matched_with": matchedWith.name,
"help_url": "https://baselhack2023-randoms.web.app/",
"help_url": "https://meetingmunch.com/",
"product_name": "MeetingMunch"
}
)
4 changes: 2 additions & 2 deletions notebooks/playground.ipynb
Expand Up @@ -124,8 +124,8 @@
"Requirement already satisfied: numpy>=1.17.3 in /home/noverney/miniconda3/lib/python3.10/site-packages (from scikit-learn) (1.23.5)\n",
"Collecting faker\n",
" Downloading Faker-19.12.0-py3-none-any.whl (1.7 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: python-dateutil>=2.4 in /home/noverney/miniconda3/lib/python3.10/site-packages (from faker) (2.8.2)\n",
"\u001B[2K \u001B[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001B[0m \u001B[32m1.7/1.7 MB\u001B[0m \u001B[31m3.0 MB/s\u001B[0m eta \u001B[36m0:00:00\u001B[0m00:01\u001B[0m00:01\u001B[0m\n",
"\u001B[?25hRequirement already satisfied: python-dateutil>=2.4 in /home/noverney/miniconda3/lib/python3.10/site-packages (from faker) (2.8.2)\n",
"Requirement already satisfied: six>=1.5 in /home/noverney/miniconda3/lib/python3.10/site-packages (from python-dateutil>=2.4->faker) (1.16.0)\n",
"Installing collected packages: faker\n",
"Successfully installed faker-19.12.0\n"
Expand Down

0 comments on commit d402b81

Please sign in to comment.