Skip to content
This repository has been archived by the owner on Jul 31, 2021. It is now read-only.

Commit

Permalink
remove incomplete users, matchwith only checks if non-invoking user c…
Browse files Browse the repository at this point in the history
…onsents
  • Loading branch information
mkofdwu committed Dec 25, 2020
1 parent 922bc93 commit 754f475
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
8 changes: 6 additions & 2 deletions admin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { migrateChatTyping } from './migrations';
// import { migrateChatTyping } from './migrations';

migrateChatTyping().then(() => console.log('DONE'));
import { removeIncompleteUsers } from './migrations';

// migrateChatTyping().then(() => console.log('DONE'));

removeIncompleteUsers().then(() => console.log('DONE'));
31 changes: 31 additions & 0 deletions admin/src/migrations.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import admin = require('firebase-admin');
import {
chatsRef,
userProfilesRef,
usersAlgorithmDataRef,
usersPrivateInfoRef,
userStatusesRef,
} from './constants';

export const migrateUserChatLastRead = async () => {
Expand Down Expand Up @@ -42,3 +44,32 @@ export const migrateChatTyping = async () => {
});
}
};

export const removeIncompleteUsers = async () => {
const allIds: Set<string> = new Set();
for (const doc of (await userProfilesRef.get()).docs) {
allIds.add(doc.id);
}
for (const doc of (await usersPrivateInfoRef.get()).docs) {
allIds.add(doc.id);
}
for (const doc of (await usersAlgorithmDataRef.get()).docs) {
allIds.add(doc.id);
}
for (const doc of (await userStatusesRef.get()).docs) {
allIds.add(doc.id);
}
for (const uid of allIds) {
if (
!(await userProfilesRef.doc(uid).get()).exists ||
!(await usersPrivateInfoRef.doc(uid).get()).exists ||
!(await usersAlgorithmDataRef.doc(uid).get()).exists ||
!(await userStatusesRef.doc(uid).get()).exists
) {
await userProfilesRef.doc(uid).delete();
await usersPrivateInfoRef.doc(uid).delete();
await usersAlgorithmDataRef.doc(uid).delete();
await userStatusesRef.doc(uid).delete();
}
}
};
7 changes: 2 additions & 5 deletions functions/src/functions/suggestions-http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,8 @@ export const matchWith = functions.https.onCall(async (data, context) => {
).data();
if (algorithmData == null || otherAlgorithmData == null)
throw 'could not get either user algorithm data';
if (
// both should be true (suggestionsGoneThrough is a map in the format {uid: liked})
!algorithmData['suggestionsGoneThrough'][otherUid] ||
!otherAlgorithmData['suggestionsGoneThrough'][uid]
) {
if (!otherAlgorithmData['suggestionsGoneThrough'][uid]) {
// verify that the other user also liked this user (note that the user invoking the function has not updated suggestionsGoneThrough yet)
throw 'failed to match, both users did not like each other';
}

Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class _TundrAppState extends State<TundrApp> {
),
accentColor: MyPalette.gold,
fontFamily: 'Liberation Sans',
cursorColor: MyPalette.white,
textSelectionTheme: TextSelectionThemeData(
cursorColor: MyPalette.white,
),
Expand Down Expand Up @@ -215,6 +216,7 @@ class _TundrAppState extends State<TundrApp> {
),
accentColor: MyPalette.gold,
fontFamily: 'Liberation Sans',
cursorColor: MyPalette.black,
textSelectionTheme: TextSelectionThemeData(
cursorColor: MyPalette.black,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/most_popular.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class _MostPopularPageState extends State<MostPopularPage> {
);
var attempts = 0;
while (_overlapsWithAny(rect: tile, otherRects: tiles) &&
attempts < 500) {
attempts < 400) {
tile = Rect.fromLTWH(
random.nextDouble() * (widget.width - size),
random.nextDouble() * (widget.height - size),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: tundr
description: tundr clean up removing support for web.

version: 0.2.1+19
version: 0.2.2+20

environment:
sdk: '>=2.2.2 <3.0.0'
Expand Down

0 comments on commit 754f475

Please sign in to comment.