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