Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation enhancement #3703

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ed981c7
feat(functions): move notification logic from discussion store to fir…
goratt12 Jun 3, 2024
37ec4b9
fix(functions): removed old tests
goratt12 Jun 4, 2024
e847de0
Merge branch 'master' into 3563-move-discussion-notifications-to-func…
goratt12 Jun 4, 2024
a6fa28d
fix(functions): fixed lint issues due to merge
goratt12 Jun 4, 2024
570d807
fix(functions): changed IDiscussionComment to IComment
goratt12 Jun 4, 2024
a770ef7
fix(functions): addressed change requests
goratt12 Jun 5, 2024
990203b
feat(functions): prevent duplicate notifications
goratt12 Jun 6, 2024
d523fef
fix(functions): comment out notification tests in discussion specs
goratt12 Jun 13, 2024
13e4afe
Merge branch 'master' into 3563-move-discussion-notifications-to-func…
goratt12 Jun 13, 2024
471917c
Merge branch 'master' into 3563-move-discussion-notifications-to-func…
goratt12 Jun 14, 2024
2c64f01
fix(functions): fix requested changes
goratt12 Jun 14, 2024
7bad0cf
feat: changes to docs
goratt12 Jun 21, 2024
a23610b
feat: more changes
goratt12 Jun 21, 2024
d81fa83
feat: bit more changes
goratt12 Jun 21, 2024
fb689ff
feat: fun changes
goratt12 Jun 21, 2024
3a9817c
fix(functions): fixed lint issues
goratt12 Jun 25, 2024
fe8a972
Merge branch 'master' into 3563-move-discussion-notifications-to-func…
benfurber Jun 25, 2024
6b78ce4
Merge branch 'documentation-enhancement' of https://github.com/goratt…
goratt12 Jun 27, 2024
22bd2db
fix(docs): working version
goratt12 Jun 27, 2024
4eabaa6
Merge branch 'master' into documentation-enhancement
goratt12 Sep 1, 2024
8e8464a
Merge branch 'master' into documentation-enhancement
goratt12 Sep 7, 2024
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
46 changes: 46 additions & 0 deletions .env-cmdrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Run a pre-flight check that developer environment setup in compatible way
import { envCheck } from './scripts/envCheck'
if (!process.env.CI) {
envCheck()
}

// Specific settings to use when running anything that requires a webpack compiler
// Enabled when npm command specifies `env-cmd -e webpack`
let webpack = {
NODE_OPTIONS: getNodeOptions(),
}

// Specific env to use with react-scripts / create-react-app
// Enabled when npm command specifies `env-cmd -e cra`
let cra = {
...webpack,
FAST_REFRESH: false,
}

exports.cra = cra
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still needed? we shouldn't use cra or webpack anymore

exports.webpack = webpack

/** Determine what node_options to provide depending on context */
function getNodeOptions() {
// Depending on node version use different environment variables to fix
// specific build or run issues
const NODE_VERSION = process.versions.node.split('.')[0]

let NODE_OPTIONS = process.env.NODE_OPTIONS || ''

// fix out-of-memory issues - default to 4GB but allow override from CI
// NOTE - would like to auto-calculate but does not support CI (https://github.com/nodejs/node/issues/27170)
if (!NODE_OPTIONS.includes('--max-old-space-size')) {
NODE_OPTIONS += ` --max-old-space-size=4096`
}
if (NODE_VERSION > '17') {
// fix https://github.com/facebook/create-react-app/issues/11708
// https://github.com/facebook/create-react-app/issues/12431
NODE_OPTIONS += ' --openssl-legacy-provider --no-experimental-fetch'
}

if (process.env.CI) {
console.log('NODE_OPTIONS', NODE_OPTIONS, '\n')
}
return NODE_OPTIONS.trim()
}
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Hey there, Future Contributor! Welcome to our project playground! Before you dive in and start contributing your awesome ideas, please take a moment to check out our [Official Documentation](https://onearmy.github.io/community-platform/).


# Contribution Guidelines

Thanks for being here already! You'll find all the information you need to start contributing to the project. Make sure to read them before submitting your contribution.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# 🔗   tl;dr Quick Links

- [Project Website](https://platform.onearmy.earth)
- [Project Kamp Community Platform (live site)](https://community.projectkamp.com/)
- [Precious Plastic Community Platform (live site)](http://community.preciousplastic.com/)
- [Fixing Fashion Community Platform (live site)](https://community.fixing.fashion/)
- [Developer documentation](https://onearmy.github.io/community-platform/)
- [Contributing Guide](/CONTRIBUTING.md)

# 🌍   Community Platform

Expand Down
37 changes: 37 additions & 0 deletions functions/src/Utils/db.utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { getDiscussionCollectionName, randomID } from './db.utils'

describe('getDiscussionCollectionName', () => {
it('should return "questions" when sourceType is "question"', () => {
const result = getDiscussionCollectionName('question')
expect(result).toBe('questions')
})

it('should return "howtos" when sourceType is "howto"', () => {
const result = getDiscussionCollectionName('howto')
expect(result).toBe('howtos')
})

it('should return null when sourceType is unrecognized', () => {
const result = getDiscussionCollectionName('unknown')
expect(result).toBe(null)
})
it('should return null when sourceType is an empty string', () => {
const result = getDiscussionCollectionName('')
expect(result).toBeNull()
})

it('should return "research" when sourceType is "researchUpdate"', () => {
const result = getDiscussionCollectionName('researchUpdate')
expect(result).toBe('research')
})
})

describe('randomID', () => {
// generates a string of length 20
it('should generate a string of length 20 and include only alphanumeric characters', () => {
const id = randomID()
const alphanumericRegex = /^[a-zA-Z0-9]+$/
expect(id).toHaveLength(20)
expect(alphanumericRegex.test(id)).toBe(true)
})
})
31 changes: 31 additions & 0 deletions functions/src/Utils/db.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export type DiscussionEndpoints = 'howtos' | 'research' | 'questions'

/**
* Function used to determine the discussion collection name based on the source type.
*/
export const getDiscussionCollectionName = (
sourceType: string,
): DiscussionEndpoints | null => {
switch (sourceType) {
case 'question':
return 'questions'
case 'howto':
return 'howtos'
case 'researchUpdate':
return 'research'
default:
return null
}
}

/**
* Function used to generate random ID in same manner as firestore
*/
export const randomID = () => {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
let autoId = ''
for (let i = 0; i < 20; i++) {
autoId += chars.charAt(Math.floor(Math.random() * chars.length))
}
return autoId
}
1 change: 1 addition & 0 deletions functions/src/Utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './auth.utils'
export * from './data.utils'
export * from './file.utils'
export * from './db.utils'
Loading
Loading