Skip to content

Commit 1699874

Browse files
authored
Merge pull request #490 from connect-foundation/Develop
PR Develop to master : releaseCode:: End game
2 parents f48eb46 + a5b68af commit 1699874

File tree

329 files changed

+3899
-3983
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

329 files changed

+3899
-3983
lines changed

backend/.env.example

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,14 @@ AUTH_PROD_TOKEN_AUDIENCE=
122122
#######################################################################################################################
123123
# redis
124124
REDIS_DEV_CONTAINER_NAME=redis_dev
125-
REDIS_DEV_PORT=6379
125+
REDIS_DEV_PORT=6380
126126
REDIS_DEV_HOST=127.0.0.1
127127

128-
REDIS_PROD_CONTAINER_NAME=redis_dev
128+
REDIS_TEST_CONTAINER_NAME=redis_test
129+
REDIS_TEST_PORT=6381
130+
REDIS_TEST_HOST=127.0.0.1
131+
132+
REDIS_PROD_CONTAINER_NAME=redis
129133
REDIS_PROD_PORT=6379
130-
REDIS_PROD_HOST=127.0.0.1
134+
REDIS_PROD_HOST=redis
131135
#######################################################################################################################
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const Adjectives = [
2+
"춤추는",
3+
"멋있는",
4+
"차가운",
5+
"뜨거운",
6+
"호기심이 많은",
7+
"귀여운",
8+
"울부짖는",
9+
"궁금한게 많은",
10+
"노래하는",
11+
"랩하는",
12+
"화사한",
13+
"맵시있는",
14+
"요리하는",
15+
"재미있는",
16+
"큰 눈의",
17+
"착한",
18+
"정직한",
19+
"조용한",
20+
"즐거운",
21+
"졸고있는",
22+
"기쁜",
23+
"벅찬",
24+
"포근한",
25+
"흐뭇한",
26+
"상쾌한",
27+
"시원한",
28+
"반가운",
29+
"후련한",
30+
"살맛 나는",
31+
"신바람 나는",
32+
"아늑한",
33+
"흥분되는",
34+
"온화한",
35+
"느긋한",
36+
"끝내주는",
37+
"괜찮은",
38+
"쌈박한",
39+
"정다운",
40+
"그리운",
41+
"자유로운",
42+
"따사로운",
43+
"감미로운",
44+
"황홀한",
45+
"상큼한",
46+
"개념있는",
47+
"지성적인",
48+
"자상한",
49+
"아리따운",
50+
"여유있는",
51+
"감정이 풍부한",
52+
"활기찬",
53+
"힘찬",
54+
"생생한",
55+
"의기 양양한",
56+
"든든한",
57+
"격렬한",
58+
"당당한",
59+
"팔팔한",
60+
"엄청난",
61+
"자신만만한",
62+
"패기만만한",
63+
"충만한",
64+
];
65+
66+
export default Adjectives;

backend/DB/dummy/RandomGuestName/Animals.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import faker from "faker";
2+
import Adjectives from "./Adjective.js";
3+
import Animals from "./Animals.js";
4+
5+
function getRandomGuestName() {
6+
const adjective = faker.random.arrayElement(Adjectives);
7+
const animal = faker.random.arrayElement(Animals);
8+
9+
return `${adjective} ${animal}`;
10+
}
11+
12+
export default getRandomGuestName;

backend/DB/logger.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import getLogger from "../libs/logger.js";
2+
3+
const logger = getLogger("mySQL_Query");
4+
5+
export default logger;

backend/DB/queries/candidate.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1+
import Sequelize from "sequelize";
12
import models from "../models";
23

3-
const Sequelize = require("sequelize");
4-
54
const Op = Sequelize.Op;
65

76
export async function getCandidatesByPollId(pollIdList) {
8-
const result = await models.Candidate.findAll({
7+
return models.Candidate.findAll({
98
where: {
109
PollId: {
1110
[Op.or]: pollIdList,
1211
},
1312
},
1413
});
15-
16-
return result;
1714
}

backend/DB/queries/event.js

Lines changed: 15 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -16,141 +16,57 @@ export async function createEvent({
1616
return models.Event.findOrCreate({
1717
where: {eventCode},
1818
defaults: {
19+
eventName,
20+
HostId,
1921
moderationOption,
2022
replyOption,
2123
startAt,
2224
endAt,
23-
HostId,
24-
eventName,
2525
},
2626
});
2727
}
2828

29-
export async function updateEventById(
29+
export async function updateEventById({
3030
id,
31-
{eventName, moderationOption, replyOption, startAt, endAt}
32-
) {
31+
eventName,
32+
moderationOption,
33+
replyOption,
34+
startAt,
35+
endAt,
36+
}) {
3337
return models.Event.update(
3438
{eventName, moderationOption, replyOption, startAt, endAt},
35-
{where: {id}}
39+
{where: {id}},
3640
);
3741
}
3842

3943
export async function getEventsByHostId(hostId) {
40-
const events = await models.Event.findAll({
44+
return models.Event.findAll({
4145
where: {HostId: hostId},
4246
});
43-
44-
return events;
4547
}
4648

47-
export async function getEventIdByEventCode(eventCode) {
48-
const event = await models.Event.findOne({
49+
export async function getEventByEventCode(eventCode) {
50+
return models.Event.findOne({
4951
where: {
5052
eventCode,
5153
},
52-
attributes: ["id"],
5354
});
54-
55-
return event;
5655
}
5756

5857
export async function getEventById(EventId) {
59-
const event = await models.Event.findOne({
58+
return models.Event.findOne({
6059
where: {
6160
id: EventId,
6261
},
6362
});
64-
65-
return event;
6663
}
6764

6865
export async function getEventOptionByEventId(id) {
69-
const event = await models.Event.findOne({
66+
return models.Event.findOne({
7067
where: {
7168
id,
7269
},
7370
attributes: ["moderationOption", "replyOption"],
7471
});
75-
76-
return event;
77-
}
78-
79-
export async function getQuestionLikeCount(EventId = 2, limit, offset) {
80-
return models.Question.findAll({
81-
attributes: ["id", [models.sequelize.fn("count", "*"), "likeCount"]],
82-
where: {EventId, QuestionId: null},
83-
include: [
84-
{
85-
model: models.Like,
86-
attributes: [],
87-
},
88-
],
89-
group: "id",
90-
offset,
91-
limit,
92-
});
93-
}
94-
95-
export async function getQuestionsByEventCodeAndGuestId(
96-
eventCode,
97-
guestId,
98-
limit = 70,
99-
offset
100-
) {
101-
// const event = await models.Event.findOne({where: {eventCode}});
102-
// const EventId = event.dataValues.id
103-
const EventId = 2;
104-
105-
return models.Question.findAll({
106-
where: {EventId, QuestionId: null},
107-
include: [
108-
{
109-
model: models.Like,
110-
},
111-
{
112-
model: models.Emoji,
113-
},
114-
{
115-
model: models.Guest,
116-
},
117-
],
118-
offset,
119-
limit,
120-
});
121-
}
122-
123-
export async function raw_getQuestionsByEventCodeAndGuestId(
124-
eventCode,
125-
guestId,
126-
limit = 100,
127-
offset = 0
128-
) {
129-
// const event = await models.Event.findOne({where: {eventCode}});
130-
// const EventId = event.dataValues.id
131-
const EventId = 2;
132-
133-
const query = `
134-
select *, Emojis.name, Emojis.GuestId
135-
from Questions
136-
inner join Emojis on Questions.id = Emojis.QuestionId
137-
where EventId = :EventId and Questions.QuestionId is null
138-
-- order by Emojis.QuestionId DESC
139-
140-
-- limit :limit offset :offset
141-
142-
-- group by Emojis.QuestionId
143-
`;
144-
// console.log(event.dataValues.id)
145-
const [questions] = await models.sequelize.query(query, {
146-
replacements: {
147-
EventId,
148-
limit,
149-
offset,
150-
type: Sequelize.QueryTypes.SELECT,
151-
raw: true,
152-
},
153-
});
154-
155-
return questions;
15672
}

backend/DB/queries/guest.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import uuidv1 from "uuid/v1";
22
import models from "../models";
3+
import getRandomGuestName from "../dummy/RandomGuestName";
34

45
const Guest = models.Guest;
56

6-
async function findGuestBySid(guestSid) {
7-
const guest = await Guest.findOne({where: {guestSid}});
8-
const result = guest ? guest.dataValues : false;
7+
async function getGuestByGuestSid(guestSid) {
8+
return Guest.findOne({where: {guestSid}});
9+
}
910

10-
return result;
11+
async function isExistGuest(guestSid) {
12+
return !!(await getGuestByGuestSid(guestSid));
1113
}
1214

13-
async function createGuest(name, eventId) {
15+
async function createGuest(eventId) {
1416
const guest = await Guest.create({
15-
name,
17+
name: getRandomGuestName(),
1618
EventId: eventId,
1719
guestSid: uuidv1(),
1820
isAnonymous: 1,
1921
});
2022

21-
const result = guest ? guest.dataValues : false;
22-
23-
return result;
23+
return guest.get({plain: true});
2424
}
2525

2626
async function getGuestById(id) {
@@ -30,10 +30,7 @@ async function getGuestById(id) {
3030
}
3131

3232
async function updateGuestById({id, name, isAnonymous, company, email}) {
33-
return Guest.update(
34-
{name, company, isAnonymous, email},
35-
{where: {id}},
36-
);
33+
return Guest.update({name, company, isAnonymous, email}, {where: {id}});
3734
}
3835

3936
async function getGuestByEventId(EventId) {
@@ -45,5 +42,6 @@ export {
4542
getGuestById,
4643
updateGuestById,
4744
getGuestByEventId,
48-
findGuestBySid,
45+
isExistGuest,
46+
getGuestByGuestSid
4947
};

backend/DB/queries/hashtag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const Hashtag = models.Hashtag;
55
export async function createHashtag({name, EventId}) {
66
return Hashtag.create(
77
{name, EventId},
8-
{default: {updateAt: new Date(), createAt: new Date()}}
8+
{default: {updateAt: new Date(), createAt: new Date()}},
99
);
1010
}
1111

backend/DB/queries/host.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
import models from "../models";
22

3-
async function findHostByAuthId(oAuthid) {
4-
const host = await models.Host.findOne({where: {oauthId: oAuthid}});
5-
const result = host ? host.dataValues : false;
3+
// todo: 더 좋은 이름
4+
export async function findHostByAuthId(oauthId) {
5+
const host = await models.Host.findOne({where: {oauthId}});
66

7-
return result;
7+
return host ? host.dataValues : false;
88
}
99

10-
async function createHost(oAuthid, name, image, email) {
10+
export async function createHost(oauthId, name, image, email) {
1111
const host = await models.Host.create({
12-
oauthId: oAuthid,
12+
oauthId,
1313
name,
1414
email,
1515
image,
16-
emailFeedBack: 0,
16+
emailFeedBack: false,
1717
});
18-
const result = host ? host.dataValues : false;
1918

20-
return result;
19+
return host ? host.dataValues : false;
2120
}
22-
23-
export {createHost, findHostByAuthId};

0 commit comments

Comments
 (0)