Skip to content

Commit

Permalink
Updated make file to run the nomis script
Browse files Browse the repository at this point in the history
  • Loading branch information
sandypadmanabhan committed Jan 25, 2021
1 parent c84e27a commit 14e7e30
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@ acceptance-web: build
test:
go test -race -cover ./...

.PHONEY: test build debug
.PHONY: nomis
nomis:
go run NOMIS/nomis.go -mongo-url=localhost:27017

.PHONY: test build debug


14 changes: 14 additions & 0 deletions NOMIS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Upload NOMIS data
==================

This utility adds the datasets, instances and edition to the dataset collection stored in mongodb.

### How to run

* Go to the root directory
* Run `make nomis`

The url should look like the following localhost:27017. If a username and password are needed, follow this structure
`<username>:<password>@<host>:<port>`


9 changes: 8 additions & 1 deletion NOMIS/main.go → NOMIS/nomis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"github.com/ONSdigital/dp-dataset-api/models"
"github.com/ONSdigital/log.go/log"
Expand Down Expand Up @@ -67,9 +68,14 @@ func CensusContactDetails() models.ContactDetails{
}

func main() {

var mongoURL string
flag.StringVar(&mongoURL, "mongo-url", "localhost:27017", "mongoDB URL")
flag.Parse()

downloadFile()
ctx := context.Background()
session, err := mgo.Dial("localhost")
session, err := mgo.Dial(mongoURL)
if err != nil {
log.Event(ctx, "failed to initialise mongo", log.FATAL, log.Error(err))
os.Exit(1)
Expand Down Expand Up @@ -209,6 +215,7 @@ func main() {
createDocument(ctx,censusEditionData,session,"editions")
createDocument(ctx,censusInstances,session,"instances")
}
fmt.Println("datasets, instances and editions have been added to datasets db")
}


Expand Down

0 comments on commit 14e7e30

Please sign in to comment.