Skip to content

Config file structure and corresponding code refactoring/optimization #13

@pavelsr

Description

@pavelsr

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions