Mileage Redeeming Program for Air China

Posted by Jianan on December 7, 2017

1 Introduction

This mileage redeeming program is used Python (pandas and TinyDB) to design a small database to store the mileage redeeming policies for Air China for clients to check what ticket they can redeem based on their mileage.

The whole program can be divivded into three parts: search function, database building, and test.

2 Part 1: Database Building

Scheme of Database

Kiku

CA_Table_One_way, CA_Table_Round, SA_Table_One_way, SA_Table_Round stands for one way gift ticket in CA, round trip in CA, one way ticket by Star Alliance (except CA) and round ticket by StarAlliance(except CA), separately.

New_User() is just a function that adds user to INFO database, use uuid5 as the identifier of a user.

INS_Log() is a logger that record each transaction to log database. Change_INFO() is to update info database when transaction happened, and total mileage should not be influence when airlines gift user a ticket.

User_buy_a_ticket() would add mileage and obviously Airline_gift_a_ticket() would substart mileage.

Search_gift_Mileage() is to get how much mileage should cost when gift a ticket to user, data comes from these four variant: CA_Table_One_way, CA_Table_Round, SA_Table_One_way, SA_Table_Round. Output_All_data() is a function that print all data in database via pandas.

User_Class_filter() is a filter that classify a user.

Note: CA: Air China; SA: Star Alliance.

Kiku

It shows the example how to store the redeeming policy of Air China.

Part 2: Test

TEST_ALL.py

Add all class in *.py in ./test and run all test in one command.

Kiku

New_User_test.py

Test if New_User() function works fine.

Kiku

Gift_ticket_test.py

Test all possibility that airlines can gift to user and check if Total_Mileage would not be changed when the clients redeem their tickets.

Kiku

User_class_test.py

Test if User_Class_filter() function works fine.

Kiku

Buy_ticket_test.py

Test User_buy_a_ticket() function.

Kiku

Part 3: Search Function

This program is to help the clients who want to redeem a free ticket by using their customer ID. Here is an example:

Kiku