Skip to content

Commit

Permalink
Update query
Browse files Browse the repository at this point in the history
  • Loading branch information
LikDan committed Nov 1, 2023
1 parent 7056342 commit 23c387a
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 796 deletions.
2 changes: 1 addition & 1 deletion cmd/studyum/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {
loadSwagger(engine.RouterGroup, "general", "auth", "user", "schedule", "journal")
setupSSL(engine.RouterGroup)

db := client.Database("Studyum")
db := client.Database("StudyumKBP")

redisClient := redis.NewClient(&redis.Options{
Addr: os.Getenv("REDIS_DB_URL"),
Expand Down
54 changes: 54 additions & 0 deletions db/queries/StudyPlaceUsers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
db.createView('StudyPlaceUsers', 'Users', [
{
"$addFields": {
"studyPlaceInfo.studyPlaceID": "$studyPlaceInfo._id",
"studyPlaceInfo._id": "$_id"
}
},
{
"$replaceRoot": {
"newRoot": "$studyPlaceInfo"
}
},
{
"$group": {
"_id": null,
"user": {
"$push": "$$ROOT"
}
}
},
{
"$lookup": {
"from": "CodeUsers",
"pipeline": [],
"as": "codeUsers"
}
},
{
"$project": {
"users": {
"$concatArrays": ["$codeUsers", "$user"]
}
}
},
{
"$unwind": "$users"
},
{
"$replaceRoot": {
"newRoot": "$users"
}
},
{
"$project": {
"_id": 1,
"studyPlaceID": 1,
"name": 1,
"role": 1,
"roleName": 1,
"tuitionGroup": 1,
"permissions": 1
}
}
])
81 changes: 0 additions & 81 deletions db/queries/getLessonInfo.sql

This file was deleted.

97 changes: 0 additions & 97 deletions db/queries/getScheduleQuery.sql

This file was deleted.

Loading

0 comments on commit 23c387a

Please sign in to comment.