Skip to content

Commit

Permalink
resolved some bugs and try to insert new icons
Browse files Browse the repository at this point in the history
  • Loading branch information
MattDEV02 committed Jan 16, 2024
1 parent 543e358 commit 4799c92
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 47 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

LambertQuiz is a React Native-based and cross-platform mobile app that offers interactive and timed quizzes on various topics.

#### P.S. = Go to Releases sections and download only the latest release (the third one).
#### P.S. = Go to Releases section and download only the latest release (the fourth one).

## Key Features ✨

Expand Down
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"slug": "LambertQuiz",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/square_logo.png",
"icon": "./assets/images/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/images/splash.png",
Expand All @@ -19,7 +19,7 @@
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/images/square_logo.png",
"foregroundImage": "./assets/images/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"package": "com.anonymous.LambertQuiz"
Expand Down
Binary file modified assets/images/adaptive-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/square_logo.png
Binary file not shown.
21 changes: 14 additions & 7 deletions lambertquiz.sql
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ $$ LANGUAGE PLPGSQL;
CREATE INDEX
users_index ON public.users USING btree (user_id);

/*
INSERT INTO
public.users (email, password, username)
VALUES
Expand All @@ -182,6 +183,8 @@ VALUES
'Matt'
);
*/

SELECT
*
FROM
Expand Down Expand Up @@ -952,16 +955,17 @@ SELECT
Other functions:
*/

CREATE
OR REPLACE FUNCTION delete_user () RETURNS VOID LANGUAGE SQL SECURITY DEFINER AS $$
OR REPLACE FUNCTION delete_user (IN input_email TEXT) RETURNS VOID LANGUAGE SQL SECURITY DEFINER AS $$
DELETE FROM auth.users
WHERE id = auth.UID();
WHERE auth.users.email = input_email;
$$;

CREATE
OR REPLACE FUNCTION get_best_five_users_stats () RETURNS TABLE (
username VARCHAR,
totalScore BIGINT,
_averageScore NUMERIC,
averageScore TEXT,
worstScore TEXT,
betterScore TEXT,
Expand All @@ -978,9 +982,10 @@ BEGIN
FROM public.Quizzes;
SELECT 5 INTO questions_number;
RETURN QUERY
SELECT DISTINCT
SELECT
DISTINCT
Users.username,
SUM(Progresses.quiz_score) AS totalScore,
ROUND(AVG(Progresses.quiz_score), 2) AS _averageScore,
ROUND(AVG(Progresses.quiz_score), 2)::VARCHAR || ' / ' || questions_number AS averageScore,
MIN(Progresses.quiz_score)::VARCHAR || ' / ' || questions_number AS worstScore,
MAX(Progresses.quiz_score)::VARCHAR || ' / ' || questions_number AS betterScore,
Expand All @@ -1000,8 +1005,8 @@ FROM
GROUP BY
Users.username
ORDER BY
averageScore,
Users.username DESC
_averageScore DESC,
Users.username ASC
LIMIT
5;
END;
Expand Down Expand Up @@ -1127,3 +1132,5 @@ $$ LANGUAGE PLPGSQL;
;

-- Example query:

select * from get_best_five_users_stats();
1 change: 0 additions & 1 deletion src/components/screens/PlayQuizScreen/Question.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const Question = ({
const handleImageError = (questionIndex) => {
let updatedImagesError = [...imagesError];
updatedImagesError[questionIndex] = true;
console.log(updatedImagesError);
setImagesError(updatedImagesError);
};

Expand Down
29 changes: 14 additions & 15 deletions src/components/screens/StatsScreen/StatsCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import moment from "moment";
import { COLORS, appName } from "../../../constants/theme";
import { validateObject } from "../../../utils/validators";

const StatsCalendar = ({ data, userSubDate, userUpdatedDate }) => {
const StatsCalendar = ({ data, user }) => {
const quizTaken = { key: "quizTaken", color: COLORS.black },
userSub = { key: "userSub", color: COLORS.white },
userUpd = { key: "userUpd", color: "#CF13A6" };
const calendarFormat = "YYYY-MM-DD";
const
_userSubDate = moment(userSubDate).format(calendarFormat),
_userUpdatedDate = moment(userUpdatedDate).format(calendarFormat);
const _userSubDate = moment(user.email_confirmed_at).format(calendarFormat),
_userUpdatedDate = moment(user.updated_at).format(calendarFormat);
let markedDates = {};
const markedDateObjProperties = {
selected: true,
Expand All @@ -38,7 +37,7 @@ const StatsCalendar = ({ data, userSubDate, userUpdatedDate }) => {
};
}

if(userSubDate !== userUpdatedDate) {
if (user.inserted_at !== user.updated_at) {
if (validateObject(markedDates[_userUpdatedDate])) {
markedDates[_userUpdatedDate].dots.push(userUpd);
} else {
Expand All @@ -48,19 +47,20 @@ const StatsCalendar = ({ data, userSubDate, userUpdatedDate }) => {
};
}
}

const handleOnPlayPress = (stringDay) => {
const base = "In " + moment(stringDay).format("DD/MM/YYYY");
const formattedStringDay = moment(stringDay).format("DD/MM/YYYY");
const base = "In day " + formattedStringDay;
const markedDate = markedDates[stringDay];
let outputString = base;
if (!validateObject(markedDate)) {
outputString += " you didn't play with us.";
outputString += " you didn't play with " + appName + ".";
} else if (
markedDate.dots.includes(quizTaken) &&
!markedDate.dots.includes(userSub) &&
!markedDate.dots.includes(userUpd)
) {
outputString += " you played with us!";
outputString += " you played with " + appName + "!";
} else if (
!markedDate.dots.includes(quizTaken) &&
markedDate.dots.includes(userSub) &&
Expand All @@ -72,7 +72,7 @@ const StatsCalendar = ({ data, userSubDate, userUpdatedDate }) => {
!markedDate.dots.includes(userSub) &&
markedDate.dots.includes(userUpd)
) {
outputString += " you updated your Account!";
outputString += " you updated your " + appName + " Account!";
} else if (
markedDate.dots.includes(quizTaken) &&
markedDate.dots.includes(userSub) &&
Expand All @@ -85,22 +85,21 @@ const StatsCalendar = ({ data, userSubDate, userUpdatedDate }) => {
!markedDate.dots.includes(userSub) &&
markedDate.dots.includes(userUpd)
) {
outputString += " you played with us and updated your account!";
outputString += " you played with us and updated your " + appName + " account!";
} else if (
!markedDate.dots.includes(quizTaken) &&
markedDate.dots.includes(userSub) &&
markedDate.dots.includes(userUpd)
) {
outputString +=
" you signed up and updated your account!";
outputString += " you signed up and updated your " + appName + " account!";
} else if (
markedDate.dots.includes(quizTaken) &&
markedDate.dots.includes(userSub) &&
markedDate.dots.includes(userUpd)
) {
outputString += " you played, signed up and updated your account!";
outputString += " you played, signed up and updated your account for " + appName + "!";
}
Window.alert(outputString);
Window.alert(formattedStringDay, outputString);
};

return (
Expand Down
8 changes: 3 additions & 5 deletions src/screens/StatsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ const StatsScreen = ({ route }) => {
const isFocused = useIsFocused();

const user = route.params.user;
console.log(user);

const userId = user.user_id;

const userSub = moment(user.email_confirmed_at).format("DD/MM/YYYY"),
userUpd = moment(user.updated_at).format("YYYY-MM-DD");
const userSub = moment(user.email_confirmed_at).format("DD/MM/YYYY");
const userSubDays = moment().diff(user.email_confirmed_at, "days") + 1;

const [bestFiveUsersMatrix, setBestFiveUsersMatrix] = useState([]); // array of arrays
Expand Down Expand Up @@ -164,8 +163,7 @@ const StatsScreen = ({ route }) => {
{validateArray(quizzesDays, 0) ? (
<StatsCalendar
data={quizzesDays}
userSubDate={user.email_confirmed_at}
userUpdatedDate={userUpd}
user={user}
/>
) : null}
</View>
Expand Down
30 changes: 19 additions & 11 deletions src/utils/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,31 @@ export const signOut = async () => {
};

export const removeUser = async (user) => {
const email = user.email;
Window.alert(
"Are your sure?",
`Are you sure you want to deleted your account with this email: ${user.email} ?`,
`Are you sure you want to deleted your account with this email: ${email} ?`,
[
{
text: "Yes",
onPress: async () => {
deleteUser(user.user_id);
Window.alert(
"Account deleted successfully",
`Your account is deleted.`,
);
signOut();
Toast.show("Account deleted.");
sendEmailForAccountDeleted(user);
const user_id = user.user_id;
if (deleteUser(user_id)) {
const { data, error } = await supabase.rpc("delete_user", {
input_email: email
});
if (validateObject(error)) {
console.error(error.message);
}
console.log("User_id " + user_id + " deleted.");
Window.alert(
"Account deleted successfully",
`Your account is deleted.`,
);
signOut();
Toast.show("Account deleted.");
sendEmailForAccountDeleted(user);
}
},
},
{
Expand All @@ -82,5 +92,3 @@ export const removeUser = async (user) => {
],
);
};


5 changes: 0 additions & 5 deletions src/utils/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ export const deleteUser = async (user_id) => {
console.error(error);
return false;
}
const { data, error2 } = await supabase.rpc("delete_user");
if (validateObject(error2)) {
console.error(error2.message);
}
console.log("User_id " + user_id + " deleted.");
return true;
};

Expand Down

0 comments on commit 4799c92

Please sign in to comment.