Giter Club home page Giter Club logo

wazoku_test's Introduction

Wazoku customer support developer test

Description

This repo represents a stripped down version of our core ideas platform product 'Idea Spotlight'. We have a customer export script named user_activity_export.sh which is run manually and collates all the user activity for a given customer across the site then emails the resulting data file to a named manager.

Getting started

Copying the repository

Due to the public nature of forks we suggest you duplicate the repo rather then forking it. You will need to create your own repo e.g. [your_github_username]/wazoku_test and then clone this repo chrispbailey/wazoku_test and push the code into your new one. You can follow the steps for doing this here: https://help.github.com/articles/duplicating-a-repository/

Before proceeded be aware that this exercise assumes you are using a linux machine with pip and virtualenv installed.

Create a new virtualenv in your checked out repo.

cd /[path_to]/wazoku_test
python3.6 -m venv .

Then install the dependencies:

bin/pip install -r requirements.txt

Set the default django settings file used by all following commands:

export DJANGO_SETTINGS_MODULE=exercise.settings

The code in this repo uses an sqlite database as the persistence layer. You can initialize an sqlite database (this db will be stored in the file ./db.sqlite3)

bin/python manage.py migrate

There is a simple django populate_db command which can be used to prime the database with some example data

bin/python manage.py populate_db

The user export script can be run with the following:

bin/python -m scripts.user_activity_export \
  -c example.com \
  -e [email protected]

There is also a unit test which can be used to validate the code:

bin/python manage.py test tests

Exercise 1

Our clients wish to receive a list of inactive users as well as active ones. Given the limitation of the csv format, we propose generating an Excel document instead of a csv file. Use the openpyxl library to modify the code to produce an xlsx document containing two sheets, the first mirrors the csv with a list of active users and their activity, the second sheet contains a list of email addresses for those users with no activity on the site. Feel free to refactor the code any way you see fit.

Please create a pull request for this work.

Exercise 2

Although the tests are all passing, after a recent refactoring this code appears to have stopped working as our customers are all reporting they are not receiving the emails when we run the script (although occasionally the wrong manager does receive an email). Please identify and fix the problem and issue a second pull request for your fix.

Bonus marks will be awarded for the addition of tests against your fix

Exercise 3

The current script is not particularly efficient against large customers. Can you improve on the current code and reduce it's complexity from O(N) to O(1). You might want to consider using assertNumQueries to help you confirm this.

Please create a third pull request for this work.

wazoku_test's People

Contributors

chrispbailey 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.