Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/ephemeral-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyvy-vi committed Aug 2, 2022
2 parents 778a460 + 28e2f77 commit 4fa2379
Show file tree
Hide file tree
Showing 84 changed files with 1,877 additions and 1,467 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 0 additions & 6 deletions docker-compose.development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ services:
links:
- api

watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --interval 1800

volumes:
mongodb_data:
caddy_data:
Expand Down
6 changes: 0 additions & 6 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ services:
links:
- api

watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --interval 43200

volumes:
mongodb_data:
caddy_data:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { SettingGroup } from '@/settings/types';
import { SettingsModel } from '../../settings/entities';

const settings = [
{
key: 'FIRST_TIME_PRAISER',
value:
'**😃 We noticed this is the first time you praise!**\n Find here some info about what makes good Praise: https://givepraise.xyz',
type: 'Textarea',
label: 'First Time Praiser Message',
description: 'Make a great new praise!',
group: SettingGroup.DISCORD,
},
];

const up = async (): Promise<void> => {
const settingUpdates = settings.map((s) => ({
updateOne: {
filter: { key: s.key },

// Insert setting if not found, otherwise continue
update: { $setOnInsert: { ...s } },
upsert: true,
},
}));

await SettingsModel.bulkWrite(settingUpdates);
};

const down = async (): Promise<void> => {
const allKeys = settings.map((s) => s.key);
await SettingsModel.deleteMany({ key: { $in: allKeys } });
};

export { up, down };
41 changes: 0 additions & 41 deletions packages/api/src/database/seeder/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,6 @@ const PERIOD_LENGTH_DAYS = 10;
const PRAISE_PER_PERIOD_NUMBER = 100;
const QUANTIFIER_USERS_NUMBER = 10;
const REGULAR_USERS_NUMBER = 10;
const PREDEFINED_USERS = [
{
ethereumAddress: '0xa32aECda752cF4EF89956e83d60C04835d4FA867', // Kristofer
roles: ['ADMIN', 'USER'],
},
{
ethereumAddress: '0x826976d7C600d45FB8287CA1d7c76FC8eb732030', // Mitch
roles: ['ADMIN', 'USER'],
},
{
ethereumAddress: '0xc617C1B5c78E76aaA33e6d1964b24A4f923077f7', // Nebs
roles: ['ADMIN', 'USER'],
},
{
ethereumAddress: '0x44FEa69505B8B3dA031Cf0cc2420f6114ED78E4f',
roles: ['USER', 'QUANTIFIER'],
},
];

/**
* Seed users into database from PREDEFINED_USERS list
*
* @returns Promise
*/
const seedPredefinedUsers = async (): Promise<void> => {
const userCount = await UserModel.count();

if (userCount < PREDEFINED_USERS.length) {
for (let i = 0; i < PREDEFINED_USERS.length; i++) {
try {
await seedUserAndUserAccount({
ethereumAddress: PREDEFINED_USERS[i].ethereumAddress,
roles: PREDEFINED_USERS[i].roles,
});
} catch (e) {
console.log('ERROR:', e);
}
}
}
};

/**
* Seed fake users into database with only USER role,
Expand Down Expand Up @@ -200,7 +160,6 @@ const seedPeriodsWithPraises = async (): Promise<void> => {
export const seedData = async (): Promise<void> => {
logger.info('Seeding database with fake data.');

await seedPredefinedUsers();
await seedRegularUsers();
await seedQuantifierUsers();

Expand Down
8 changes: 4 additions & 4 deletions packages/api/src/period/controllers/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ export const all = async (

const periodList = response?.docs;
if (periodList && Array.isArray(periodList) && periodList.length > 0) {
const periodDetailsList: PeriodDetailsDto[] = [];
const periodDetailsDto: PeriodDetailsDto[] = [];
for (const period of periodList) {
if (period?.status === PeriodStatusType.QUANTIFY) {
const periodDetails = await findPeriodDetailsDto(period._id);
periodDetailsList.push(periodDetails);
periodDetailsDto.push(periodDetails);
continue;
}
periodDetailsList.push(periodTransformer(period));
periodDetailsDto.push(periodTransformer(period));
}
res.status(StatusCodes.OK).json({
...response,
docs: periodDetailsList,
docs: periodDetailsDto,
});
} else {
res.status(StatusCodes.OK).json({
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const setupDatabase = async (NODE_ENV = 'development'): Promise<void> => {
const setupApiServer = async (NODE_ENV = 'development'): Promise<Express> => {
const app = express();

//app.use((req, res, next) => setTimeout(next, 1000)); // Delay response during testing

app.use(
fileUpload({
createParentPath: true,
Expand Down
Loading

0 comments on commit 4fa2379

Please sign in to comment.