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

make updateRoom Query #11 #34

Merged
merged 5 commits into from
Oct 6, 2018
Merged

make updateRoom Query #11 #34

merged 5 commits into from
Oct 6, 2018

Conversation

kannanhassouna
Copy link
Collaborator

@kannanhassouna kannanhassouna commented Oct 3, 2018

make updateRoom query and remove useless console.log() ,
make available rooms query and test it and convert all callback queries to promises .
and utilities functions helps in getting final available rooms and test them .

updateRoom

the input should be object contain the data about the Room and the output should be the count of effected rows

the input

  const roomObject = {
    room_num: 1,
    description: 'first decsription',
    price: 100,
    imgs: 'img url',
    services: 'first serveices',
    type: 'single',
 };
updateRoom(roomObject);

the output

1

availableRooms

the input should be object contain the reservation start date and the reservation end date and the type of room and the result is the available Rooms with it's prices .

the input

 avaliableRooms({ from: '2017-05-01', to: '2017-06-06', type: 'single' });

the output

[
        { number: 1, price: 100 },
        { number: 2, price: 100 },
        { number: 3, price: 100 },
        { number: 4, price: 100 },
        { number: 5, price: 100 },
        { number: 6, price: 100 },
        { number: 7, price: 100 },
        { number: 8, price: 100 },
        { number: 9, price: 100 }
]

Utilities Functions

removeDuplicated

that accepts array contain duplicated rows and remove them by using room_num and the elements of the array is object contain the room number and the room price .

the input

  const array = [{
    id: 1,
    room_num: 1,
    price: 100,
  },
  {
    id: 1,
    room_num: 1,
    price: 100,
  },
  {
    id: 2,
    room_num: 2,
    price: 100,
  },
  {
    id: 2,
    room_num: 2,
    price: 100,
  },
  {
    id: 2,
    room_num: 2,
    price: 100,
  },
  ];
 removeDuplicated(array);

the output

[{ room_num: 1, price: 100 }, { room_num: 2, price: 100 }]

filterResult

that takes the order from date and the order to date and array of all reservations in database and check all reservations if the reservations fail in between the from date and to date it's removed from array .

the input

const data = [
    {
      reservation_from: '2014-04-01',
      reservation_to: '2014-04-05',
    },
    {
      reservation_from: '2015-05-05',
      reservation_to: '2015-06-04',
    },
    {
      reservation_from: '2015-06-05',
      reservation_to: '2015-06-29',
    },
  ];
filterResult('2014-05-05', '2014-05-08', data);

the output

 [
    {
      reservation_from: '2014-04-01',
      reservation_to: '2014-04-05',
    },
    {
      reservation_from: '2015-05-05',
      reservation_to: '2015-06-04',
    },
    {
      reservation_from: '2015-06-05',
      reservation_to: '2015-06-29',
    },
  ];

@kannanhassouna kannanhassouna removed their assignment Oct 5, 2018
@donia98
Copy link
Collaborator

donia98 commented Oct 6, 2018

Good job 👍

@donia98 donia98 merged commit 0181960 into master Oct 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants