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

Config file structure and corresponding code refactoring/optimization #13

Open
6 tasks
pavelsr opened this issue Mar 19, 2017 · 0 comments
Open
6 tasks
Assignees

Comments

@pavelsr
Copy link
Member

pavelsr commented Mar 19, 2017

I suggest to improve it

  • Convert "instructors: {}" to array ("instructors:[]") and remove gmail as unique id
  • Replace id on telegram_id for better clearance
  • Add service_account section that will indicate gmail account where booking information is stored (good for clearance and easier to app setup). Now it's hardcoded in bot.pl
  • Inside of service account and "calendars":[] section . So you will be able to refer a calendar only by its name and don't need to check its ID.
  • Ability to automatically fill first_name and last_name from Telegram
  • Remove durations and implement it in code

Now minimal config looks like:

{
	"token": "",
	"language": "English",
	"timezone": "Europe/Moscow",
	"workinghours": "08:00-00:00",
	"resources": {
		"Lasersaur": {
			"calendar": "b7qv527m99oqlq3md28cof16jc@group.calendar.google.com"
		}
	},
	"durations": {
		"30_min": 30,
		"1_hour": 60,
		"2_hours": 120,
		"3_hours": 180
	},
	"instructors": {
		"pavel.p.serikov@gmail.com": {
			"id": "218718957", 
			"phone_number": "79885851900",
			"first_name": "Pavel",         
			"last_name": "Serikov"			
		}
	}
}

So it will looks like:

"service_account": {
        "user": "fablab61ru@gmail.com",
        "calendars": [ "Lasersaur", "Dobot", "CTC", "Silhouette"],
       "booking_limit_per_user": 5
    },

"instructors": [
        {
            "first_name": "Pavel",
            "last_name": "Serikov",
            "gmail": "pavel.p.serikov@gmail.com",
            "phone_number": "+79885851900",
            "telegram_id": "@serikoff",
            "calendars": [ "Lasersaur", "Dobot" ]
        },
        {
            "first_name": "Vlad",
            "last_name": "Shvager",
            "gmail": "vlad-shvager@yandex.ru",
            "phone_number": "+79885851900",
            "telegram_id": "@Shvager",
            "calendars": [ "Lasersaur" ]
        }
    ]

AND! It's a good idea to migrate to one config file based on Config::JSON which allow to write in it and is used by my API::Google lib.
It will allow to remove Mojolicious from main bot.pl dependencies so docker image will take less space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant