Code Monkey home page Code Monkey logo

intercom's Introduction

Technical Problem

Problem statement

We have some customer records in a text file (customers.txt) -- one customer per line, JSON lines formatted. We want to invite any customer within 100km of our Dublin office for some food and drinks on us. Write a program that will read the full list of customers and output the names and user ids of matching customers (within 100km), sorted by User ID (ascending).

  • You must use the first formula from this Wikipedia article to calculate distance. Don't forget, you'll need to convert degrees to radians.
  • The GPS coordinates for our Dublin office are 53.339428, -6.257664
  • You can find the Customer list here.

Usage

Binaries are published in the format: https://github.com/OkBeacon/intercom/releases/download/$GIT_TAG/beer-and-cheer-go-$SYSTEM-$PLAFORM

  • On macOS, you would need to run the following and then add to your path:
curl -LO "https://github.com/OkBeacon/intercom/releases/download/v1.0/beer-and-cheer-darwin-10.6-amd64" && chmod +x beer-and-cheer-darwin-10.6-amd64
  • On Windows you could install from this link or if you have curl installed then run the following and then add to your path:
curl -LO "https://github.com/OkBeacon/intercom/releases/download/v1.0/beer-and-cheer-windows-4.0-amd64.exe"

Developer guide

  • Code Structure
.
├── customer - This package holds types and methods required to implement Customers
│  ├──  customerMethods.go
│  ├──  customerMethods_test.go
│  └──  customerTypes.go

├── helper - This package holds types and methods required to implement utilities
│  ├──  utilMethods.go
│  ├──  utilMethods_test.go
│  └──  utilTypes.go

├──  main.go
└──  README.md

- Program execution starts in main.go
  1. Using utility functions in helper package, it fetches text file from Url and returns the list of strings representings lines in file
  2. For each line,
      a. Cutomer is created with by parsing the json
      b. If the customer is whithin 100km radius, it's userID and Name is appended to the list-of-customers-invited-for-Beer
  3. Sort the list-of-customers-invited-for-Beer by userID
  4. Print list-of-customers-invited-for-Beer

  • To make changes, clone this repo and make changes to required package along with required test cases
  • To test locally
$ make test
go test ./...
?       intercom        [no test files]
ok      intercom/customer       (cached)
ok      intercom/helper (cached)
  • To run locally
$ make run
go run main.go
  4  |  Ian Kehoe
  5  |  Nora Dempsey
  6  |  Theresa Enright
  8  |  Eoin Ahearn
 11  |  Richard Finnegan
 12  |  Christina McArdle
 13  |  Olive Ahearn
 15  |  Michael Ahearn
 17  |  Patricia Cahill
 23  |  Eoin Gallagher
 24  |  Rose Enright
 26  |  Stephen McArdle
 29  |  Oliver Ahearn
 30  |  Nick Enright
 31  |  Alan Behan
 39  |  Lisa Ahearn
  • To publish, tag the code to trigger a github-action pipeline which will:
    • Execute tests
    • Build binaries for targets: windows/amd64, linux/amd64, darwin/amd64
    • Create new release with given tag For example - to create beer-and-cheer v1.0
$ git tag -a v1.0 -m "Prod Ready Version"
$ git push origin v1.0

Build/Release

Gh-Actions

intercom's People

Contributors

dumberdore avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.