Skip to content

Instantly share code, notes, and snippets.

@ybky42
Last active July 12, 2023 12:12
Show Gist options
  • Save ybky42/c98f58a0d55cf713fc8814dc0c526bb1 to your computer and use it in GitHub Desktop.
Save ybky42/c98f58a0d55cf713fc8814dc0c526bb1 to your computer and use it in GitHub Desktop.

YBKY saralash bosqichi topshirig'i

Impactt co-working markazi rezidentlariga majlis xonalarni oldindan oson band qilish uchun tizim yaratmoqchi va bunda sizning yordamingiz kerak.

Backend yo'nalishiga topshirganlar tizim uchun REST API tuzishi kerak bo'ladi. Frontend yo'nalishi qatnashchilaridan esa ushbu tizim uchun foydalanuvchi interfeysini yasash kutiladi.

Tizimning funksional talablari:

  • Xonalar haqida ma'lumot saqlash va taqdim qila olish;
  • Xonani ko'rsatilgan vaqt oralig'i uchun band qila olish;
  • Bir xonaning band qilingan vaqtlari ustma-ust tushmasligi kerak;
  • Autentifikatsiya (login) imkoniyatini qo'shish talab qilinmaydi.

Ko'p so'ralgan savollar:

  • Qaysi dasturlash tilidan foydalanish kerak? Istalgan!
  • Kutubxona va freymvorklardan foydalanish mumkinmi? Ha.
  • Qaysi ma'lumotlar omboridan foydalanish mumkin? Fuksional talablarni qondiradigan istalgan ma'lumotlar omboridan foydalanishingiz mumkin.

Loyihani topshirish uchun talablar.

  • GitHubda private repozitoriya yarating
  • Ishingizni bosqichma-bosqich commit qilib boring
  • GitHub repozitoriyaning settings qismidan ybky42 foydalanuvchisini Collaborator sifatida qo'shing.
  • 20-iyunga qadar loyihani yakunlab, Pull Request yaratib, ybky42 foydalanuvchisini Reviewer sifatida qo'shing.
  • Savollaringizni ushbu gist ostidagi izohlarda qoldiring.

Mavjud xonalarni olish uchun API

GET /api/rooms

Parametrlar:

  • search: Xona nomi orqali qidirish
  • type: xona turi bo'yicha saralash (focus, team, conference)
  • page: sahifa tartib raqami
  • page_size: sahifadagi maksimum natijalar soni

HTTP 200

{
  "page": 1,
  "count": 3,
  "page_size": 10,
  "results": [
    {
      "id": 1,
      "name": "mytaxi",
      "type": "focus",
      "capacity": 1
    },
    {
      "id": 2,
      "name": "workly",
      "type": "team",
      "capacity": 5
    },
    {
      "id": 3,
      "name": "express24",
      "type": "conference",
      "capacity": 15
    }
  ]
}

Xonani id orqali olish uchun API

GET /api/rooms/{id}

HTTP 200

{
  "id": 3,
  "name": "express24",
  "type": "conference",
  "capacity": 15
}

HTTP 404

{
  "error": "topilmadi"
}

Xonaning bo'sh vaqtlarini olish uchun API

GET /api/rooms/{id}/availability

Parametrlar:

  • date: sana (ko'rsatilmasa bugungi sana olinadi)

Response 200

[
  {
    "start": "05-06-2023 9:00:00",
    "end": "05-06-2023 11:00:00"
  },
  {
    "start": "05-06-2023 13:00:00",
    "end": "05-06-2023 18:00:00"
  }
]

Xonani band qilish uchun API

POST /api/rooms/{id}/book
{
  "resident": {
    "name": "Anvar Sanayev"
  },
  "start": "05-06-2023 9:00:00",
  "end": "05-06-2023 10:00:00"
}

HTTP 201: Xona muvaffaqiyatli band qilinganda

{
  "message": "xona muvaffaqiyatli band qilindi"
}

HTTP 410: Tanlangan vaqtda xona band bo'lganda

{
  "error": "uzr, siz tanlagan vaqtda xona band"
}
@elyorxon
Copy link

test_failed
Bitta failed test qoldi. 3-4 kundan beri ovoraman. Natijaga oz qoldi...

@dilshodturabov
Copy link

dilshodturabov commented Jun 29, 2023 via email

@dilshodturabov
Copy link

image

bitta shu fail bo'layapti :-|

@eugene0928
Copy link

Assalomu aleykum menda bir muammo qancha to'g'irlashga urunmasam ham hech o'zgarmayapti? Shu bilan menda bir savol tug'uldi! men node.js express.js da ushbu topshiriqni bajarganman lekin testlar Pythonda qilingan. Bu yerda mendan boshqa odam ham bormi nodejs orqali bajarib hamma testdan pass bo'lgan? Eng qizig'i shundaki so'ralgan hamma requestlarga aytilganidek programmam javob berayapti lekin testga qo'ysam birorta test muvoffaqiyatli chiqmayapti, keyin nimaga shunday bo'layapti deb bing AI dan so'rab ko'rdim. U shunday javob berdi: It looks like you are trying to pass some tests in Python using the requests library. The tests are failing because the response status code is 404 instead of the expected 200. This means that the server could not find the requested resource. You may want to check if the API URL is correct and if the server is running.

As for Node.js, it is a different language and runtime environment from Python. You would need to rewrite the tests using a Node.js testing framework and an HTTP client library for Node.js. Nima qilsam bo'ladi? Lekin rosssssssa qatnashgim kelayapti shu YBKY ga. hozir nima qilishni bilmayapman. Yozgan dasturmni manually postman orqali test qilish jarayonini video qilib yuborsam bo'lmaydimi. Hamma testcaselarni manuall qilsam kutganimdek javob qaytarayapti lekin, jprq test! Iltimos maslahat beringizlar endi men qatnasha olmimanmi?

o'xshadimi sizda?

@dilshodturabov
Copy link

dilshodturabov commented Jun 29, 2023 via email

@eugene0928
Copy link

image

bitta shu fail bo'layapti :-|

bunda 1chi end time bilan undan keyingi start time bir xil bolib qolish ehtimolini hisobga olganmidiz?

E.p:

[
     {start: "30-06-2023 08:31:00", end: "30-06-2023 09:00:00}, 
     {start: "30-06-2023 09:00:00", end: "30-06-2023 10:00:00},
     {start: "30-06-2023 10:00:00", end: "30-06-2023 19:00:00}
 ]

shu holatni nazarda tutgandim :)

@murod110
Copy link

@azimjohn uzur xato o'zimda ekan 100% passed bo'ldi.

@elyorxon
Copy link

@elyorxon
Copy link

@azimjohn bitta test fail bo'lyapti. "Stack" bo'lib qoldim. Yo'nalish berib yubora olasizmi? def test_get_available_rooms_pagination():
params = {"page": 1, "page_size": 2}
response = requests.get(API_URL, params=params)
assert response.status_code == 200

    data = response.json()
   assert "page" in data

AssertionError: assert 'page' in {'count': 3, 'next': 'http://elyorxon.jprq.live/api/rooms/?page=2&page_size=2', 'previous': None, 'results': {'count': 3, 'page': 1, 'page_size': 2, 'results': [{'capacity': 1, 'id': 1, 'name': 'mytaxi', 'type': 'focus'}, {'capacity': 5, 'id': 2, 'name': 'workly', 'type': 'team'}]}}

test_ybky.py:79: AssertionError

@Mirxojiddin
Copy link

@azimjohn bitta test fail bo'lyapti. "Stack" bo'lib qoldim. Yo'nalish berib yubora olasizmi? def test_get_available_rooms_pagination(): params = {"page": 1, "page_size": 2} response = requests.get(API_URL, params=params) assert response.status_code == 200

    data = response.json()
   assert "page" in data

AssertionError: assert 'page' in {'count': 3, 'next': 'http://elyorxon.jprq.live/api/rooms/?page=2&page_size=2', 'previous': None, 'results': {'count': 3, 'page': 1, 'page_size': 2, 'results': [{'capacity': 1, 'id': 1, 'name': 'mytaxi', 'type': 'focus'}, {'capacity': 5, 'id': 2, 'name': 'workly', 'type': 'team'}]}}

test_ybky.py:79: AssertionError

page resultni ichida bo'lmasligi kerak
resultni ichida faqat xonaga oid ma'lumotlar bo'lishi kerak

@Mirxojiddin
Copy link

@azimjohn bitta test fail bo'lyapti. "Stack" bo'lib qoldim. Yo'nalish berib yubora olasizmi? def test_get_available_rooms_pagination(): params = {"page": 1, "page_size": 2} response = requests.get(API_URL, params=params) assert response.status_code == 200

    data = response.json()
   assert "page" in data

AssertionError: assert 'page' in {'count': 3, 'next': 'http://elyorxon.jprq.live/api/rooms/?page=2&page_size=2', 'previous': None, 'results': {'count': 3, 'page': 1, 'page_size': 2, 'results': [{'capacity': 1, 'id': 1, 'name': 'mytaxi', 'type': 'focus'}, {'capacity': 5, 'id': 2, 'name': 'workly', 'type': 'team'}]}}
test_ybky.py:79: AssertionError

Taxminan shunaqa natija qaytishi kerak

HTTP 200

{
  "page": 1,
  "count": 3,
  "page_size": 2,
  "results": [
    {
      "id": 1,
      "name": "mytaxi",
      "type": "focus",
      "capacity": 1
    },
    {
      "id": 2,
      "name": "workly",
      "type": "team",
      "capacity": 5
    },
    
  ]
}

@dilshodturabov
Copy link

image
bitta shu fail bo'layapti :-|

bunda 1chi end time bilan undan keyingi start time bir xil bolib qolish ehtimolini hisobga olganmidiz?

E.p:

[
     {start: "30-06-2023 08:31:00", end: "30-06-2023 09:00:00}, 
     {start: "30-06-2023 09:00:00", end: "30-06-2023 10:00:00},
     {start: "30-06-2023 10:00:00", end: "30-06-2023 19:00:00}
 ]

shu holatni nazarda tutgandim :)

hoz kallam qaynab ketayapti nima qilishni bilmasdan qoldim boshida qanaqadur tushungandek bo`lib harakat qilib ko'rdim hoz vaqt tugayotganiga nima qilayotganimni ham aslida nima qilish kerakligini ham tushunmasdan qoldim :help

@dilshodturabov
Copy link

@azimjohn bitta test fail bo'lyapti. "Stack" bo'lib qoldim. Yo'nalish berib yubora olasizmi? def test_get_available_rooms_pagination(): params = {"page": 1, "page_size": 2} response = requests.get(API_URL, params=params) assert response.status_code == 200

    data = response.json()
   assert "page" in data

AssertionError: assert 'page' in {'count': 3, 'next': 'http://elyorxon.jprq.live/api/rooms/?page=2&page_size=2', 'previous': None, 'results': {'count': 3, 'page': 1, 'page_size': 2, 'results': [{'capacity': 1, 'id': 1, 'name': 'mytaxi', 'type': 'focus'}, {'capacity': 5, 'id': 2, 'name': 'workly', 'type': 'team'}]}}

test_ybky.py:79: AssertionError

mendagi fail bo`lgan testni siz qanday solve qilgansiz?

@elyorxon
Copy link

@Mirxojiddin javobingiz uchun tashakkur! Shu narsani drf paginationda chiqarish muammo bo'lyapti-da.

@dilshodturabov
Copy link

image
bitta shu fail bo'layapti :-|

bunda 1chi end time bilan undan keyingi start time bir xil bolib qolish ehtimolini hisobga olganmidiz?
E.p:

[
     {start: "30-06-2023 08:31:00", end: "30-06-2023 09:00:00}, 
     {start: "30-06-2023 09:00:00", end: "30-06-2023 10:00:00},
     {start: "30-06-2023 10:00:00", end: "30-06-2023 19:00:00}
 ]

shu holatni nazarda tutgandim :)

shunda start bilan endni vaqti bir xil bo'lmasligi kerakmi ?

@sarvar-akbarov
Copy link

image
bitta shu fail bo'layapti :-|

bunda 1chi end time bilan undan keyingi start time bir xil bolib qolish ehtimolini hisobga olganmidiz?
E.p:

[
     {start: "30-06-2023 08:31:00", end: "30-06-2023 09:00:00}, 
     {start: "30-06-2023 09:00:00", end: "30-06-2023 10:00:00},
     {start: "30-06-2023 10:00:00", end: "30-06-2023 19:00:00}
 ]

shu holatni nazarda tutgandim :)

shunda start bilan endni vaqti bir xil bo'lmasligi kerakmi ?

qaysidir kundagi bo'sh vaqtlarni olishda usha kun (00:00:00 dan 23:59:59) dan barcha band qilingan intervallarni chiqarib tashlashiz kerak

@dilshodturabov
Copy link

image
bitta shu fail bo'layapti :-|

bunda 1chi end time bilan undan keyingi start time bir xil bolib qolish ehtimolini hisobga olganmidiz?
E.p:

[
     {start: "30-06-2023 08:31:00", end: "30-06-2023 09:00:00}, 
     {start: "30-06-2023 09:00:00", end: "30-06-2023 10:00:00},
     {start: "30-06-2023 10:00:00", end: "30-06-2023 19:00:00}
 ]

shu holatni nazarda tutgandim :)

shunda start bilan endni vaqti bir xil bo'lmasligi kerakmi ?

qaysidir kundagi bo'sh vaqtlarni olishda usha kun (00:00:00 dan 23:59:59) dan barcha band qilingan intervallarni chiqarib tashlashiz kerak

Shunday qilayapman yana nimagadur o'tmayapti bu evil testdan, 😭😵 zombie ga o'xshab qoldim uyqusizlikdan. Hali yana tekshiriladimi yozgan codlarimiz? men o'ta olmimanmi endi bitta shuni deb🥺. Qancha xarakat qilganman axir iltimos meni yolg'iz tashlab ketmangizlar. Shunaqangi Azimjon aka bilan YBKYda dars qilgim kelayapti. Menga vaqt yetmasdan qoldi. Hozir ...

@khotamb
Copy link

khotamb commented Jun 30, 2023

image
bitta shu fail bo'layapti :-|

bunda 1chi end time bilan undan keyingi start time bir xil bolib qolish ehtimolini hisobga olganmidiz?
E.p:

[
     {start: "30-06-2023 08:31:00", end: "30-06-2023 09:00:00}, 
     {start: "30-06-2023 09:00:00", end: "30-06-2023 10:00:00},
     {start: "30-06-2023 10:00:00", end: "30-06-2023 19:00:00}
 ]

shu holatni nazarda tutgandim :)

shunda start bilan endni vaqti bir xil bo'lmasligi kerakmi ?

qaysidir kundagi bo'sh vaqtlarni olishda usha kun (00:00:00 dan 23:59:59) dan barcha band qilingan intervallarni chiqarib tashlashiz kerak

Shunday qilayapman yana nimagadur o'tmayapti bu evil testdan, 😭😵 zombie ga o'xshab qoldim uyqusizlikdan. Hali yana tekshiriladimi yozgan codlarimiz? men o'ta olmimanmi endi bitta shuni deb🥺. Qancha xarakat qilganman axir iltimos meni yolg'iz tashlab ketmangizlar. Shunaqangi Azimjon aka bilan YBKYda dars qilgim kelayapti. Menga vaqt yetmasdan qoldi. Hozir ...

Hali 23 soat 48minut vaqt bor :)
https://gist.github.com/ybky42/c98f58a0d55cf713fc8814dc0c526bb1?permalink_comment_id=4609668#gistcomment-4609668

@Ozodbek00
Copy link

Bir oz kechikadigandekman. Nimada xalolik beryotganini tushunmagandim jprq ni ishlatolmagandim. git da project ni master ga merge qilib pull qilib olish esimadan chiqqan ekan...

@JabborovEgamberdi
Copy link

jprq ni qanaqa qilib install qilinadi ? Biladiganlar yozvorila. Rahmat oldindan

@dilshodturabov
Copy link

dilshodturabov commented Jul 2, 2023 via email

@JabborovEgamberdi
Copy link

Qaysi OSga install qilmoqchisiz

On Sun, Jul 2, 2023, 4:00 PM Jabborov_Egamberdi_IUT < @.> wrote: @.* commented on this gist. ------------------------------ jprq ni qanaqa qilib install qilinadi ? Biladiganlar yozvorila. Rahmat oldindan — Reply to this email directly, view it on GitHub https://gist.github.com/ybky42/c98f58a0d55cf713fc8814dc0c526bb1#gistcomment-4616569 or unsubscribe https://github.com/notifications/unsubscribe-auth/AUL5AUWFA6M4KXHMNOSO263XOFIELBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTEMRXHEZDQNBYU52HE2LHM5SXFJTDOJSWC5DF . You are receiving this email because you commented on the thread. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

Windows

@dilshodturabov
Copy link

dilshodturabov commented Jul 2, 2023

@aslbek-dev
Copy link

jprq ni qanaqa qilib install qilinadi ? Biladiganlar yozvorila. Rahmat oldindan.
Sizda hali ham loyhani test qiladigan page ishlayaptimi

@JabborovEgamberdi
Copy link

bolla tugadimi Backend 2 bosqich ???

@JabborovEgamberdi
Copy link

@azimjohn
Copy link

azimjohn commented Jul 3, 2023

3 kun bo'ldi tugaganiga

@IFUITU
Copy link

IFUITU commented Jul 6, 2023

@azimjohn Joylar soni to'lib bo'ldimi? Bonus sifatida 2-3 joy uchun testlarni yana 1 kunga ochib turaolmaysizmi? Joy topilmasa yerda ham o'tiraveramiz.

@dilshodturabov
Copy link

dilshodturabov commented Jul 6, 2023 via email

@piterpool
Copy link

@azimjohn Joylar soni to'lib bo'ldimi? Bonus sifatida 2-3 joy uchun testlarni yana 1 kunga ochib turaolmaysizmi? Joy topilmasa yerda ham o'tiraveramiz.

+++

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