Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into improvement/async-mem…
Browse files Browse the repository at this point in the history
…ber-affiliations-update
  • Loading branch information
loicsaintroch committed Jan 8, 2024
2 parents 888766d + c67928e commit 023f608
Show file tree
Hide file tree
Showing 64 changed files with 1,706 additions and 1,314 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
DO $$
DECLARE
_member_id UUID;
_first_acitivity TIMESTAMP;
BEGIN
FOR _member_id IN
SELECT id
FROM members
WHERE EXTRACT(YEAR FROM "joinedAt") = 1970 -- those who have the wrong joinedAt
AND EXISTS ( -- yet have at least one activity with a non-1970 timestamp
SELECT 1
FROM activities a
WHERE a."memberId" = members.id
AND EXTRACT(YEAR FROM a.timestamp) != 1970
)
LOOP
RAISE NOTICE 'member_id: %', _member_id;

-- find the actual first non-1970 activity timestamp
SELECT MIN(a.timestamp) INTO _first_acitivity
FROM activities a
WHERE EXTRACT(YEAR FROM a.timestamp) != 1970
AND a."memberId" = _member_id;

IF _first_acitivity IS NULL THEN
CONTINUE;
END IF;

RAISE NOTICE 'first_acitivity: %', _first_acitivity;

UPDATE members
SET "joinedAt" = _first_acitivity
WHERE id = _member_id;
END LOOP;
END;
$$;
29 changes: 16 additions & 13 deletions backend/src/database/repositories/memberRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2220,26 +2220,29 @@ class MemberRepository {
const memberIds = translatedRows.map((r) => r.id)
if (memberIds.length > 0) {
const seq = SequelizeRepository.getSequelize(options)
const segmentIds = segments

const lastActivities = await seq.query(
`
WITH
raw_data AS (
SELECT *, ROW_NUMBER() OVER (PARTITION BY "memberId" ORDER BY timestamp DESC) AS rn
FROM activities
WHERE "tenantId" = :tenantId
AND "memberId" IN (:memberIds)
AND "segmentId" IN (:segmentIds)
)
SELECT *
FROM raw_data
WHERE rn = 1;
WITH
leaf_segment_ids AS (
select id
from segments
where "tenantId" = :tenantId and "parentSlug" is not null and "grandparentSlug" is not null
),
raw_data AS (
SELECT *, ROW_NUMBER() OVER (PARTITION BY "memberId" ORDER BY timestamp DESC) AS rn
FROM activities
INNER JOIN leaf_segment_ids ON activities."segmentId" = leaf_segment_ids.id
WHERE "tenantId" = :tenantId
AND "memberId" IN (:memberIds)
)
SELECT *
FROM raw_data
WHERE rn = 1;
`,
{
replacements: {
tenantId: tenant.id,
segmentIds,
memberIds,
},
type: QueryTypes.SELECT,
Expand Down
13 changes: 13 additions & 0 deletions frontend/package-lock.json

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

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"@octokit/core": "^3.6.0",
"@tiptap/extension-link": "^2.1.12",
"@tiptap/extension-placeholder": "^2.1.12",
"@tiptap/pm": "^2.1.12",
"@tiptap/starter-kit": "^2.1.12",
"@tiptap/vue-3": "^2.1.12",
"@tiptap/pm": "^2.1.12",
"@vitejs/plugin-vue": "^4.2.3",
"@vue/eslint-config-airbnb": "^7.0.0",
"@vuelidate/core": "^2.0.1",
Expand Down Expand Up @@ -74,6 +74,7 @@
},
"devDependencies": {
"@tailwindcss/line-clamp": "^0.4.2",
"@types/pluralize": "^0.0.33",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@vue/compiler-sfc": "^3.2.29",
Expand Down
53 changes: 0 additions & 53 deletions frontend/src/assets/scss/buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -310,59 +310,6 @@
@apply -mr-0.5;
}

// Identities
.btn {
&--twitter,
&--twitter:hover {
@apply bg-white border border-gray-200;
}

&--discord,
&--discord:hover {
background-color: rgba(88, 101, 242, 0.15);
}

&--crunchbase,
&--crunchbase:hover {
background: rgba(20, 106, 255, 0.15);
}

&--hackernews,
&--hackernews:hover {
background-color: rgba(255, 102, 0, 0.15);
color: #ff6600;
}

&--email,
&--email:hover,
&--phone,
&--phone:hover,
&--custom-platform,
&--custom-platform:hover,
&--facebook,
&--facebook:hover {
@apply leading-none cursor-pointer bg-white text-gray-600 border border-gray-200;
}

&--github,
&--github:hover,
&--devto,
&--devto:hover {
@apply bg-gray-100 border border-gray-200;
}

&--slack,
&--slack:hover,
&--linkedin,
&--linkedin:hover,
&--stackoverflow,
&--stackoverflow:hover,
&--git,
&--git:hover {
@apply bg-white border border-gray-200;
}
}

.el-button {
--el-button-outline-color: transparent !important;
}
13 changes: 7 additions & 6 deletions frontend/src/middleware/auth/auth-guard.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ export default async function ({
return;
}

if (!currentUser.acceptedTermsAndPrivacy) {
router.push({ path: '/auth/terms-and-privacy' });
return;
}

if (store.getters['auth/currentTenant'] && isTrialExpired(store.getters['auth/currentTenant'])) {
if (!window.location.href.includes('/onboard/plans') && !window.location.href.includes('/onboard/payment')) {
if (!window.location.href.includes('/onboard/plans')
&& !window.location.href.includes('/onboard/payment')) {
window.location.href = `${config.frontendUrl.protocol}://${config.frontendUrl.host}/onboard/plans`;
}
return;
Expand All @@ -70,11 +76,6 @@ export default async function ({
return;
}

if (!currentUser.acceptedTermsAndPrivacy) {
router.push({ path: '/auth/terms-and-privacy' });
return;
}

if (
['multi', 'multi-with-subdomain'].includes(
config.tenantMode,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/auth/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export default {
})
.then(() => {
commit('EMAIL_VERIFY_SUCCESS');
router.push('/');
router.push('/onboard/plans');
})
.catch((error) => {
Errors.handle(error);
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/modules/auth/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export default {
payload.currentUser,
);
if (state.currentTenant && isTrialExpired(state.currentTenant)) {
if (!window.location.href.includes('/onboard/plans') && !window.location.href.includes('/onboard/payment')) {
if (!window.location.href.includes('/onboard/plans')
&& !window.location.href.includes('/onboard/payment')
&& !window.location.href.includes('/auth/verify-email')) {
window.location.href = `${config.frontendUrl.protocol}://${config.frontendUrl.host}/onboard/plans`;
}
return;
Expand Down Expand Up @@ -120,7 +122,9 @@ export default {
payload.currentUser,
);
if (state.currentTenant && isTrialExpired(state.currentTenant)) {
if (!window.location.href.includes('/onboard/plans') && !window.location.href.includes('/onboard/payment')) {
if (!window.location.href.includes('/onboard/plans')
&& !window.location.href.includes('/onboard/payment')
&& !window.location.href.includes('/auth/verify-email')) {
window.location.href = `${config.frontendUrl.protocol}://${config.frontendUrl.host}/onboard/plans`;
}
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
>
<div v-if="findPlatform(key)">
<el-form-item class="h-14 !flex items-center">
<div :class="value.imgContainerClass">
<div class="h-8 w-8 flex items-center justify-center text-base">
<img
:src="findPlatform(key).image"
:alt="findPlatform(key).name"
Expand Down Expand Up @@ -89,7 +89,10 @@
</div>
<div class="flex items-start justify-between mt-24">
<div class="flex items-center flex-1">
<app-platform platform="email" />
<app-platform-icon
platform="emails"
size="small"
/>
<div class="font-medium text-sm ml-3">
Email address
</div>
Expand All @@ -114,6 +117,7 @@ import {
} from 'vue';
import { CrowdIntegrations } from '@/integrations/integrations-config';
import cloneDeep from 'lodash/cloneDeep';
import AppPlatformIcon from '@/shared/modules/platform/components/platform-icon.vue';
const emit = defineEmits(['update:modelValue']);
const props = defineProps({
Expand Down Expand Up @@ -176,72 +180,54 @@ const identitiesForm = reactive({
props.modelValue.username?.devto !== undefined
|| false,
urlPrefix: 'dev.to/',
imgContainerClass:
'h-8 w-8 rounded flex items-center justify-center text-base bg-gray-100 border border-gray-200',
},
discord: {
enabled:
props.modelValue.username?.discord !== undefined
|| false,
urlPrefix: 'discord.com/',
imgContainerClass:
'h-8 w-8 rounded flex items-center justify-center text-base btn--discord cursor-auto hover:cursor-auto',
},
github: {
enabled:
props.modelValue.username?.github !== undefined
|| false,
urlPrefix: 'github.com/',
imgContainerClass:
'h-8 w-8 rounded flex items-center justify-center text-base bg-gray-100 border border-gray-200',
},
slack: {
enabled:
props.modelValue.username?.slack !== undefined
|| false,
urlPrefix: 'slack.com/',
imgContainerClass:
'h-8 w-8 rounded flex items-center justify-center text-base btn--slack cursor-auto hover:cursor-auto bg-white border border-gray-200',
},
twitter: {
enabled:
props.modelValue.username?.twitter !== undefined
|| false,
urlPrefix: 'twitter.com/',
imgContainerClass:
'h-8 w-8 rounded flex items-center justify-center text-base btn--twitter',
},
linkedin: {
enabled:
props.modelValue.username?.linkedin !== undefined
|| false,
urlPrefix: 'linkedin.com/in/',
imgContainerClass:
'h-8 w-8 rounded flex items-center justify-center text-base btn--linkedin',
},
reddit: {
enabled:
props.modelValue.username?.reddit !== undefined
|| false,
urlPrefix: 'reddit.com/user/',
imgContainerClass:
'h-8 w-8 rounded flex items-center justify-center text-base btn--reddit',
},
hackernews: {
enabled:
props.modelValue.username?.hackernews !== undefined
|| false,
urlPrefix: 'news.ycombinator.com/user?id=',
imgContainerClass:
'h-8 w-8 rounded flex items-center justify-center text-base btn--hackernews',
},
stackoverflow: {
enabled:
props.modelValue.username?.stackoverflow
!== undefined || false,
urlPrefix: 'stackoverflow.com/users/',
imgContainerClass:
'h-8 w-8 rounded flex items-center justify-center text-base btn--stackoverflow',
},
});
Expand Down
Loading

0 comments on commit 023f608

Please sign in to comment.