Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution by @ghanithan using a tree data-structure and a lookup map as an index #173

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0adcca2
feat: Config, CSV loading, DMA datastructure
ghanithan Oct 25, 2024
42711c8
loaded the lookup for places data and working on distributor
ghanithan Oct 26, 2024
20129d1
introduced multi branch tree structure for places
ghanithan Oct 26, 2024
2bdc319
Inclusion and exclusion constraints added
ghanithan Oct 26, 2024
7ed03f6
working on refactoring
ghanithan Oct 27, 2024
fd5f00b
Feat: data structure is complete and handler structure is setup
ghanithan Oct 30, 2024
48975fb
Adding list places and add distribution handlers
ghanithan Nov 1, 2024
aa2c7dc
added patch, and get permission handlers
ghanithan Nov 2, 2024
129a54f
to rename the folder in github
ghanithan Nov 2, 2024
fd92772
rename folder in github
ghanithan Nov 2, 2024
b0b1d1f
rearranged code
ghanithan Nov 2, 2024
89c304b
openapi spec added
ghanithan Nov 2, 2024
3eabc36
deploy to render and binary file
ghanithan Nov 2, 2024
9bea420
making render work
ghanithan Nov 2, 2024
ebb413a
update render depoy file
ghanithan Nov 2, 2024
be36bec
deleting workflow
ghanithan Nov 2, 2024
cb20a32
render issue
ghanithan Nov 2, 2024
e74b33a
comment envvar
ghanithan Nov 2, 2024
f1d418a
change plan
ghanithan Nov 2, 2024
cd47ad6
select free plan
ghanithan Nov 2, 2024
91da177
free tier
ghanithan Nov 2, 2024
f8c8afb
no preview for free
ghanithan Nov 2, 2024
2658d5d
reinit mod
ghanithan Nov 2, 2024
0406f7b
import issue resolved
ghanithan Nov 2, 2024
8e1f000
gracefull shutdown, CORS resolved, removing binaries
ghanithan Nov 2, 2024
fcac5b3
compression not working in render
ghanithan Nov 2, 2024
6a7d91a
re arrange open api
ghanithan Nov 2, 2024
3db9b77
spell correction
ghanithan Nov 2, 2024
b373e15
Added few more examples in adding distributor
ghanithan Nov 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Real Image Challenge 2016


## Solution

The solution has been completed as per specification and the solution has been hosted in render.com
[https://challenge2016.onrender.com/](https://challenge2016.onrender.com/)

It is hosted in free tier, so there will be a warm-up time close to 1 min. After the initial warm-up it would
provide a fast response.

The endpoints are described in the OpenApi Spec (./openapispec_v1.yaml). The same can be viewed using [https://editor.swagger.io/](https://editor.swagger.io/)

I am looking forward to do a detailed write-up about the approch.



In the cinema business, a feature film is usually provided to a regional distributor based on a contract for exhibition in a particular geographical territory.

Each authorization is specified by a combination of included and excluded regions. For example, a distributor might be authorzied in the following manner:
Expand Down
21 changes: 21 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package config

type ConifgService interface {
GetConfig(...string) *Config
}

type (
Config struct {
Data Data `yaml:"data"`
HttpServer HttpServer `yaml:"httpserver"`
}

Data struct {
FilePath string `yaml:"filepath"`
}

HttpServer struct {
Host string `yaml:"host"`
Port string `yaml:"port"`
}
)
37 changes: 37 additions & 0 deletions config/getConfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package config

import (
"os"

"github.com/ghanithan/challenge2016/instrumentation"
"gopkg.in/yaml.v3"
)

func GetConfig(logger instrumentation.GoLogger, args ...string) (*Config, error) {
//init config struct
config := &Config{}

// set default file path
filePath := "../setting/sample.yaml"
// collect the filepath from varidac arguments if provided
if len(args) > 0 {
filePath = args[0]
}
logger.Info(filePath)

// read the file
file, err := os.Open(filePath)
if err != nil {
return nil, err
}
defer file.Close()

// unmarshal the yaml file into conifg struct
decoder := yaml.NewDecoder(file)
decoder.KnownFields(true)
if err := decoder.Decode(&config); err != nil {
return nil, err
}

return config, nil
}
32 changes: 32 additions & 0 deletions config/getConfig_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package config

import (
"reflect"
"testing"

"github.com/ghanithan/challenge2016/instrumentation"
)

func TestGetConfig(t *testing.T) {
t.Run(
"Testing getConfig",
func(t *testing.T) {
want := &Config{
Data: Data{
FilePath: "../cities.csv",
},
}

logger := instrumentation.InitInstruments()

got, err := GetConfig(logger)
if err != nil {
t.Fatalf("Error in fetching config: %s", err)
}
if !reflect.DeepEqual(want, got) {
t.Fatalf("expected %q got %q", want, got)

}
},
)
}
Loading