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

Mia Ajuda V3.0.0 (Corgi) #163

Merged
merged 139 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
b04ad09
Create structure for social network
darmsDD Jun 20, 2022
3ace212
Add more functions to socialNetwork
darmsDD Jun 22, 2022
3cec8d8
Adiciona pesquisa por usuários
darmsDD Jul 6, 2022
b326aac
Add get activities, follow and unfollow functions.
darmsDD Aug 18, 2022
296ab13
Init getFollowers
darmsDD Aug 20, 2022
616dc09
Complete add getFollowers/getFollowing routes and rename variables
darmsDD Aug 21, 2022
f78b029
Add follow/following counter to user profile
darmsDD Aug 22, 2022
145870e
feat: create offers seed
sudjoao Sep 8, 2022
63df9cc
feat: create entity seed
sudjoao Sep 8, 2022
2a05e5e
feat: create campaign seed
sudjoao Sep 8, 2022
4503566
Revert "feat: create campaign seed"
sudjoao Sep 8, 2022
16bbd96
Revert "feat: create entity seed"
sudjoao Sep 8, 2022
7ab0883
Revert "feat: create offers seed"
sudjoao Sep 8, 2022
a4b3888
feat: create offers seed
sudjoao Sep 8, 2022
ae36127
feat: create entity seed
sudjoao Sep 8, 2022
e93008f
feat: create campaign seed
sudjoao Sep 8, 2022
f60f6d9
feat: add campaign create code
sudjoao Sep 9, 2022
f4145cf
fix: :broom: lint
sudjoao Sep 10, 2022
bb13ea5
Merge pull request #141 from mia-ajuda/feat/new-seeds
sudjoao Sep 10, 2022
7fd5a34
Adiciona notificação para os seguidores(não testado)
darmsDD Nov 2, 2022
c5b51ae
chore: change title and description in seeds to pt-br
sudjoao Jan 23, 2023
08ca7dc
fix: correct lint
sudjoao Jan 23, 2023
2935bf5
Merge pull request #145 from mia-ajuda/fix-improve-seeds
sudjoao Jan 23, 2023
fd858ba
Merge branch 'develop' into grafos_redeSocial
sudjoao Feb 18, 2023
d9570c5
chore: fix get followers logic
sudjoao Feb 18, 2023
88d1f95
Merge branch 'develop' into grafos_redeSocial
sudjoao Feb 18, 2023
6d759bd
chore: run lint fix
sudjoao Feb 18, 2023
c91f8e2
fix: fix eslint
sudjoao Feb 18, 2023
b065fc9
chore: lint again
sudjoao Feb 19, 2023
e08964d
chore: this rule doesnt make any sense =)
sudjoao Feb 19, 2023
e429db7
chore: tired of eslint
sudjoao Feb 19, 2023
3f39985
chore: removing console logs
sudjoao Feb 21, 2023
2c6d768
chore: fix lint
sudjoao Feb 21, 2023
c021adb
Merge pull request #146 from mia-ajuda/grafos_redeSocial
sudjoao Feb 22, 2023
b488e39
refactor: pass commom fields to help user query
guibrbs Mar 1, 2023
b8e3620
chore: add missing parameter
sudjoao Mar 2, 2023
a71e18a
Merge pull request #147 from mia-ajuda/HOTFIX-add-missing-parameter
sudjoao Mar 2, 2023
1060573
chore: change finduser param to query
sudjoao Apr 2, 2023
b808a60
feat: add index in username
sudjoao Apr 2, 2023
3c2903e
chore: refact social network repository and add nullable operator
sudjoao Apr 7, 2023
a8d17e6
chore: add photo to user profile return
sudjoao Apr 8, 2023
a7c8bc9
chore: return users cpf
sudjoao Apr 9, 2023
c013c4d
chore: return creationdate in getByIdWithAggregation
sudjoao Apr 9, 2023
15c9803
Merge pull request #148 from mia-ajuda/222-FollowUsersFlow
sudjoao Apr 9, 2023
31cac14
refactor: improve social network repository logics
sudjoao Apr 15, 2023
e5efd33
chore: refact some logics in order to return the right data to front
sudjoao Apr 15, 2023
da2f0cc
Merge branch 'develop' into 230-UserProfiles
sudjoao Apr 15, 2023
62b072c
chore: fix lint
sudjoao Apr 15, 2023
2497a67
chore: removing unnecessary console
sudjoao Apr 15, 2023
772a86a
chore: auto lint of vscode is different of backend lint :poop:
sudjoao Apr 15, 2023
580f84d
chore: update lint version
sudjoao Apr 15, 2023
ae5ee55
Merge branch 'develop' into 220-RefactorMyOfferDetailsPage
guibrbs Apr 20, 2023
45954a3
refactor: refact populate logic in aggregation
guibrbs Apr 20, 2023
ae37433
Merge pull request #149 from mia-ajuda/220-RefactorMyOfferDetailsPage
guibrbs Apr 20, 2023
4878159
Merge branch 'develop' into 230-UserProfiles
sudjoao Apr 21, 2023
e24f369
chore: fix lint
sudjoao Apr 21, 2023
9e92770
Merge pull request #150 from mia-ajuda/230-UserProfiles
sudjoao Apr 21, 2023
7693eca
feat: create initial badge structure
sudjoao Apr 21, 2023
761be8c
chore: update file names
sudjoao Apr 21, 2023
8c5703b
feat: create logic to create badges
sudjoao Apr 21, 2023
6fb814a
feat: create badges seed
sudjoao Apr 21, 2023
26be4a3
chore: create logic to update or create a new badge
sudjoao Apr 21, 2023
eecd09a
feat: create logic to update badge reference
sudjoao Apr 21, 2023
33565f7
feat: create logic to get badge history
sudjoao Apr 22, 2023
6573a16
chore: fix iconnames in mocked badge
sudjoao Apr 22, 2023
31d3fe6
chore: create logic to parse badges by category
sudjoao Apr 23, 2023
869ac70
chore: removing console.log
sudjoao Apr 23, 2023
2ab9c68
chore: change badge ids to number to make the logic easier
sudjoao Apr 23, 2023
27df25e
chore: create a new badge parser
sudjoao Apr 23, 2023
abe7fc7
Merge pull request #151 from mia-ajuda/224-BadgesList
sudjoao Apr 25, 2023
f37ec50
chore: add biography to user model and to edit user route
sudjoao Apr 29, 2023
80a5cd3
chore: add biography to entity model and to edit entity route
sudjoao Apr 29, 2023
7cb7b82
feat: return list of campaigns to user profile
sudjoao Apr 29, 2023
6f76dcc
Merge pull request #152 from mia-ajuda/238-EditProfile
sudjoao Apr 29, 2023
ebac5fe
chore: update seeds
sudjoao May 4, 2023
a6c629a
feat: create logic to populate badge
sudjoao May 4, 2023
c5b1bf9
chore: add await to save erorr async func
sudjoao May 4, 2023
e8e6796
chore: return help creation date
sudjoao May 7, 2023
7559fde
feat: add address state to return in help API
guibrbs May 13, 2023
c6a94cb
Merge pull request #153 from mia-ajuda/225-OfferBadge
sudjoao May 16, 2023
a8981f2
Merge pull request #154 from mia-ajuda/233-NewActivity
sudjoao May 18, 2023
1ff2fce
fix: fixing lint
guibrbs May 19, 2023
f20e646
Merge pull request #155 from mia-ajuda/239-RefactorMyRequestScreen
guibrbs May 19, 2023
0f31287
feat: returns from backend the offer distance
guibrbs May 19, 2023
52044d8
feat: returns from backend the activity type
guibrbs May 20, 2023
9680463
chore: create feedback initial structure
sudjoao Jun 4, 2023
7effb7b
feat: improve feedback model and methods returns
sudjoao Jun 4, 2023
baafeac
chore: fix filter
sudjoao Jun 4, 2023
d6f6791
Merge pull request #156 from mia-ajuda/231-FeedbackFlow
sudjoao Jun 5, 2023
39879d7
chore: add location to the user, again
sudjoao Jun 10, 2023
8fadf50
chore: create logic to notify users when a request is created
sudjoao Jun 10, 2023
2d4e3cb
chore: move notify logic to notification service
sudjoao Jun 10, 2023
faaa509
chore: fix lint
sudjoao Jun 10, 2023
69476e4
chore: i dont know why this file were here
sudjoao Jun 10, 2023
09675be
chore: ooops, a wild console log appears
sudjoao Jun 10, 2023
302d6db
Merge remote-tracking branch 'origin' into 239-RefactorMainScreen
sudjoao Jun 14, 2023
79d2e46
Merge pull request #157 from mia-ajuda/235-NewNotifications
guibrbs Jun 17, 2023
f2f6a0a
Merge remote-tracking branch 'origin/develop' into 240-RefactorMainSc…
guibrbs Jun 17, 2023
8d1573d
chore: update mocked badges
sudjoao Jun 20, 2023
384648b
feat: add new fields in badge model and create logic to mark as viewed
sudjoao Jun 20, 2023
70e638e
chore: removing consoles
sudjoao Jun 22, 2023
38ad36e
fix: fix missing category array
guibrbs Jun 23, 2023
c546824
feat: create timeline event structure
sudjoao Jun 24, 2023
548b09e
feat: create help timeline events
sudjoao Jun 24, 2023
6e36d0d
chore: fix lint
sudjoao Jun 24, 2023
859ce93
feat: add more timeline events creations
sudjoao Jun 24, 2023
f602b06
feat: create activity api
guibrbs Jun 25, 2023
ffae23c
feat: handle with distance in help offer
guibrbs Jun 25, 2023
f4f0ae1
feat: create util to sort activities by distance
guibrbs Jun 25, 2023
f1a8c4a
feat: create util to add help type to list
guibrbs Jun 25, 2023
d25b199
chore: change icons
sudjoao Jun 25, 2023
1bdaba6
feat: add coords to help offers list api
guibrbs Jun 26, 2023
308775a
fix: add missing method param
guibrbs Jun 26, 2023
cdbb14c
fix: lint fixes
guibrbs Jun 26, 2023
07495fc
fix: fix activity coords in other users profile
guibrbs Jun 26, 2023
d893e14
fix: fix requested changes
guibrbs Jun 28, 2023
b78d278
fix: fixing lint
guibrbs Jun 28, 2023
600f659
fix: fix duplicated code
guibrbs Jun 28, 2023
59a0065
fix: add arrow function to activities hash
guibrbs Jun 29, 2023
523cd4c
Merge pull request #160 from mia-ajuda/feat/create-activity-api
guibrbs Jun 29, 2023
e140375
Merge remote-tracking branch 'origin/develop' into 240-RefactorMainSc…
guibrbs Jun 29, 2023
418dedd
fix: fix campaign query method param
guibrbs Jul 2, 2023
afa330b
feat: add index to each activity array
guibrbs Jul 2, 2023
924772f
fix: removing unnecessary method
guibrbs Jul 2, 2023
a5c10b7
chore: improve logic to not return virtual to front
sudjoao Jul 2, 2023
099e0de
chore: create virtual to avoid unnecessary loop
sudjoao Jul 2, 2023
a27a562
Merge pull request #161 from mia-ajuda/240-RefactorMainScreen
guibrbs Jul 5, 2023
2e044fd
Merge branch 'develop' into 236-Timeline
sudjoao Jul 8, 2023
3b8e2da
Merge branch 'develop' into 226-FinishOfferBadge
sudjoao Jul 8, 2023
86e5f64
Merge branch 'develop' into fix/wrong-helpoffer-return
sudjoao Jul 8, 2023
00b3e1c
Merge pull request #159 from mia-ajuda/236-Timeline
sudjoao Jul 8, 2023
cf5d3a5
Merge branch 'develop' into fix/wrong-helpoffer-return
sudjoao Jul 8, 2023
a8d9f42
chore: create index field in activities
sudjoao Jul 8, 2023
21b6124
chore: create function to populate index in old activities
sudjoao Jul 8, 2023
1f9ab28
chore: remove unecessary null
sudjoao Jul 8, 2023
37f484b
chore: change index
sudjoao Jul 8, 2023
5dddb0e
Merge pull request #162 from mia-ajuda/fix/wrong-helpoffer-return
sudjoao Jul 8, 2023
06b1556
Merge pull request #158 from mia-ajuda/226-FinishOfferBadge
sudjoao Jul 16, 2023
50f7707
Merge branch 'master' into develop
sudjoao Sep 19, 2023
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
Binary file removed .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 2020
},
"rules": {
"indent": [
Expand Down
11 changes: 9 additions & 2 deletions src/config/database.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
const mongoose = require('mongoose');
const CategorySeed = require('../utils/seed/CategorySeed');
const UserSeed = require('../utils/seed/UserSeed');
const HelpSeed = require('../utils/seed/HelpSeed');
const HelpSeed = require('../utils/seed/HelpOfferCampaignSeed');
const NotificationSeed = require('../utils/seed/NotificationSeed');
const BadgeSeed = require('../utils/seed/BadgeTemplateSeed');
const TimelineEventTemplateSeed = require('../utils/seed/TimelineEventTemplateSeed');

const databaseURL = process.env.DATABASE_URL || 'mongodb://mongo:27017/miaAjudaDB';
const envType = process.env.NODE_ENV || 'development';

const databaseConnect = async () => {
try {
await mongoose.connect(databaseURL, { useNewUrlParser: true, useUnifiedTopology: true });
await mongoose.connect(databaseURL, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
console.log('Banco de dados conectado!');
mongoose.set('useFindAndModify', false);

Expand All @@ -19,6 +24,8 @@ const databaseConnect = async () => {
await UserSeed();
await HelpSeed();
await NotificationSeed();
await BadgeSeed();
await TimelineEventTemplateSeed();
}
} catch (err) {
console.log('Não foi possível inicicializar corretamente a base de dados!');
Expand Down
32 changes: 32 additions & 0 deletions src/controllers/ActivityController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const ActivityService = require('../services/ActivityService');

class ActivityController {
constructor() {
this.ActivityService = new ActivityService();
}

async fetchActivityList(req, res) {
const { id } = req.query;
const { isUserEntity } = global;
const coords = req.query.coords.split(',').map((coord) => Number(coord));
const categoryArray = req.query.categoryId?.split(',');
const activitiesArray = req.query.activityId?.split(',') || ['getAll'];
const getOtherUsers = req.query.getOtherUsers === 'true';

try {
const activityList = await this.ActivityService.fetchActivityList(
coords,
id,
isUserEntity,
categoryArray,
activitiesArray,
getOtherUsers,
);
return res.json(activityList);
} catch (error) {
return res.status(400).json({ error: error.message });
}
}
}

module.exports = ActivityController;
75 changes: 75 additions & 0 deletions src/controllers/BadgeController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const BadgeService = require('../services/BadgeService');
const saveError = require('../utils/ErrorHistory');
const parseBadgeByCategory = require('../utils/parseBadgeByCategory');

class BadgeController {
constructor() {
this.BadgeService = new BadgeService();
}

async updateOrCreateBadge(req, res, next) {
const { userId, category } = req.body;

try {
let result = await this.BadgeService.createOrUpdateBadge(
userId,
category,
);
if (
result.badge.template.nextBadge
&& result.badge.currentValue >= result.badge.template.nextBadge.neededValue
) {
result = await this.BadgeService.updateBadgeReference(result.badge);
}
res.status(201).json(result);
next();
} catch (err) {
await saveError(err);
res.status(400).json({ error: err.message });
next();
}
}

async getBadgeHistory(req, res, next) {
const userId = req.query.userId || null;
try {
const userBadges = await this.BadgeService.getBadgeList(userId);
const allBadges = await this.BadgeService.getAllBadges();
const parsedUserBadges = parseBadgeByCategory(userBadges);
res.status(200).json({ userBadges: parsedUserBadges, allBadges });
next();
} catch (err) {
await saveError(err);
res.status(400).json({ error: err.message });
next();
}
}

async getBadgeList(req, res, next) {
const userId = req.query.userId || null;
try {
const result = await this.BadgeService.getBadgeList(userId);
res.status(200).json(result);
next();
} catch (err) {
await saveError(err);
res.status(400).json({ error: err.message });
next();
}
}

async markBadgeAsViewed(req, res, next) {
const { badgeId } = req.params;
try {
await this.BadgeService.markBadgeAsViewed(badgeId);
res.status(200).json({ message: 'Badge visualized' });
next();
} catch (err) {
await saveError(err);
res.status(400).json({ error: err.message });
next();
}
}
}

module.exports = BadgeController;
5 changes: 4 additions & 1 deletion src/controllers/EntityController.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class EntityController {
notificationToken: req.body.notificationToken,
deviceId: req.body.deviceId,
address: req.body.address,
biography: req.body.biography,
};
try {
const result = await this.entityService.editEntityById(data);
Expand Down Expand Up @@ -122,7 +123,9 @@ class EntityController {
}

try {
const result = await this.entityService.checkEntityExistence(entityIdentifier);
const result = await this.entityService.checkEntityExistence(
entityIdentifier,
);
res.status(200).json(result);
next();
} catch (err) {
Expand Down
43 changes: 43 additions & 0 deletions src/controllers/FeedbackController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const FeedbackService = require('../services/FeedbackService');
const TimelineEventService = require('../services/TimelineEventService');
const saveError = require('../utils/ErrorHistory');
const timelineEnum = require('../utils/enums/timelineEnum');

class FeedbackController {
constructor() {
this.FeedbackService = new FeedbackService();
this.TimelineEventService = new TimelineEventService();
}

async create(req, res) {
try {
const { message, sender, receiver } = req.body;
const feedback = {
sender,
receiver,
message,
};
const newFeedback = await this.FeedbackService.create(feedback);
await this.TimelineEventService.create({ user: sender, template: timelineEnum.feedback });
res.status(200).json(newFeedback);
} catch (error) {
saveError(error);
res.status(500).json({ error: 'Erro ao criar feedback' });
}
}

async listByReceiver(req, res) {
try {
const { receiver } = req.params;
const feedbacks = await this.FeedbackService.listByReceiver(
receiver,
);
res.status(200).json(feedbacks);
} catch (error) {
saveError(error);
res.status(500).json({ error: 'Erro ao listar feedbacks' });
}
}
}

module.exports = FeedbackController;
7 changes: 6 additions & 1 deletion src/controllers/HelpController.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
const HelpService = require('../services/HelpService');
const UserService = require('../services/UserService');
const TimelineEventService = require('../services/TimelineEventService');
const saveError = require('../utils/ErrorHistory');
const timelineEnum = require('../utils/enums/timelineEnum');

class HelpController {
constructor() {
this.HelpService = new HelpService();
this.UserService = new UserService();
this.TimelineEventService = new TimelineEventService();
}

async createHelp(req, res, next) {
const data = {
...req.body,
};

try {
await this.HelpService.createHelp(data);
await this.TimelineEventService.create({ user: data.ownerId, template: timelineEnum.createRequest });
res.status(201).send();
next();
} catch (err) {
Expand Down Expand Up @@ -119,6 +122,7 @@ class HelpController {

try {
await this.HelpService.ownerConfirmation(data);
await this.TimelineEventService.create({ user: data.ownerId, template: timelineEnum.finishRequest });
res.status(204).send();
next();
} catch (err) {
Expand Down Expand Up @@ -147,6 +151,7 @@ class HelpController {

try {
await this.HelpService.addPossibleHelpers(id, idHelper);
await this.TimelineEventService.create({ user: idHelper, template: timelineEnum.offerHelp });
res.status(204).send();
next();
} catch (err) {
Expand Down
7 changes: 6 additions & 1 deletion src/controllers/HelpOfferController.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
const HelpOfferService = require('../services/HelpOfferService');
const TimelineEventService = require('../services/TimelineEventService');
const saveError = require('../utils/ErrorHistory');
const timelineEnum = require('../utils/enums/timelineEnum');

class OfferedHelpController {
constructor() {
this.HelpOfferService = new HelpOfferService();
this.TimelineEventService = new TimelineEventService();
}

async createHelpOffer(req, res) {
try {
const newHelpOffer = await this.HelpOfferService.createNewHelpOffer(
req.body,
);
await this.TimelineEventService.create({ user: req.body.ownerId, template: timelineEnum.offer });
return res.json(newHelpOffer);
} catch (error) {
return res.status(400).json({ error: error.message });
Expand All @@ -35,8 +39,9 @@ class OfferedHelpController {
const { userId } = req.query;
const getOtherUsers = req.query.getOtherUsers === 'true';
const { isUserEntity } = global;
const coords = req.query.coords?.split(',')?.map((coord) => Number(coord)) || '';
try {
const helpOffers = await this.HelpOfferService.listHelpsOffers(userId, isUserEntity, null, getOtherUsers);
const helpOffers = await this.HelpOfferService.listHelpsOffers(userId, isUserEntity, null, getOtherUsers, coords);
return res.json(helpOffers);
} catch (error) {
return res.status(400).json({ error: error.message });
Expand Down
Loading