chores
This commit is contained in:
parent
04e022f4d8
commit
64ad60a8e2
4 changed files with 26 additions and 22 deletions
|
|
@ -1,13 +1,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"gopkg.in/mgo.v2"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"log"
|
||||
)
|
||||
|
||||
func writeSpaceData(data SpaceData) {
|
||||
if(data.Space != "") {
|
||||
if data.Space != "" {
|
||||
session, err := mgo.Dial(config.MongoDbServer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -17,7 +17,7 @@ func writeSpaceData(data SpaceData) {
|
|||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("spacedata")
|
||||
_, err = c.Upsert(bson.M{ "space": data.Space }, data)
|
||||
_, err = c.Upsert(bson.M{"space": data.Space}, data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
@ -34,9 +34,9 @@ func writeSpaceurl(spaceUrl SpaceUrl) {
|
|||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("spaceurl")
|
||||
count, _ := c.Find(bson.M{ "url": spaceUrl.Url }).Count()
|
||||
if(count == 0) {
|
||||
c.Insert(spaceUrl);
|
||||
count, _ := c.Find(bson.M{"url": spaceUrl.Url}).Count()
|
||||
if count == 0 {
|
||||
c.Insert(spaceUrl)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ func writeCalendar(calendar Calendar) {
|
|||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("calendar")
|
||||
c.Upsert(bson.M{ "space": calendar.Space }, calendar)
|
||||
c.Upsert(bson.M{"space": calendar.Space}, calendar)
|
||||
}
|
||||
|
||||
func updateSpaceurl(spaceUrl SpaceUrl) {
|
||||
|
|
@ -63,7 +63,7 @@ func updateSpaceurl(spaceUrl SpaceUrl) {
|
|||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("spaceurl")
|
||||
c.Update(bson.M{ "url": spaceUrl.Url }, spaceUrl);
|
||||
c.Update(bson.M{"url": spaceUrl.Url}, spaceUrl)
|
||||
}
|
||||
|
||||
func readSpacedata() []SpaceData {
|
||||
|
|
@ -98,7 +98,7 @@ func readSpaceurl() []SpaceUrl {
|
|||
return result
|
||||
}
|
||||
|
||||
func deleteSpaceurl(String id) {
|
||||
func deleteSpaceurl(id string) {
|
||||
session, err := mgo.Dial(config.MongoDbServer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ func loadSpaceData() {
|
|||
if(spaceUrl.Validated && int64(spaceUrl.LastUpdated + 60) < timestamp) {
|
||||
spaceData := SpaceData{}
|
||||
err := getJson(spaceUrl.Url, &spaceData)
|
||||
if err != nil
|
||||
if(err != nil)
|
||||
{
|
||||
log.Println(spaceUrl.Url)
|
||||
log.Println(err)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
type SpaceUrl struct {
|
||||
Id string `json:"id"`
|
||||
Url string `json:"url"`
|
||||
Validated bool `json:"validated"`
|
||||
LastUpdated int64 `json:"lastUpdated"`
|
||||
|
|
|
|||
|
|
@ -1,17 +1,20 @@
|
|||
version: "3"
|
||||
services:
|
||||
frontend:
|
||||
build: ./frontend
|
||||
image: gidsi/spaceapi-ccc-frontend:latest
|
||||
restart: always
|
||||
depends_on:
|
||||
- backend
|
||||
backend:
|
||||
build: ./backend
|
||||
image: gidsi/spaceapi-ccc-backend:latest
|
||||
env_file: .env
|
||||
restart: always
|
||||
environment:
|
||||
- SHARED_SECRET=${SHARED_SECRET:-secret}
|
||||
depends_on:
|
||||
- database
|
||||
database:
|
||||
image: mongo:latest
|
||||
restart: always
|
||||
volumes:
|
||||
- /opt/eva:/data/db
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue