mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 15:43:16 +02:00
Klasy+funkcje do uzupełnienia kwerendami
This commit is contained in:
parent
1370cde9a0
commit
782f1c806b
24
analitics/MockUps.py
Normal file
24
analitics/MockUps.py
Normal file
@ -0,0 +1,24 @@
|
||||
from User import User
|
||||
from Ranting import Ranting
|
||||
|
||||
users = [
|
||||
User(1, "Lola"),
|
||||
User(2, "Tony"),
|
||||
User(3, "Lorry"),
|
||||
User(4, "Betty")
|
||||
]
|
||||
|
||||
rantings = [
|
||||
Ranting(1, 1, 1, 5, "15-06-2024 15:04:32"),
|
||||
Ranting(2, 1, 2, 6, "15-06-2024 15:04:36"),
|
||||
Ranting(3, 2, 1, 7, "15-06-2024 15:04:40"),
|
||||
Ranting(4, 2, 2, 8, "15-06-2024 15:04:44"),
|
||||
Ranting(5, 2, 3, 9, "15-06-2024 15:04:48"),
|
||||
Ranting(6, 3, 1, 10, "15-06-2024 15:04:52"),
|
||||
Ranting(7, 3, 2, 6, "15-06-2024 15:04:56"),
|
||||
Ranting(8, 3, 3, 5, "15-06-2024 15:05:00"),
|
||||
Ranting(9, 4, 1, 4, "15-06-2024 15:05:04"),
|
||||
Ranting(10, 4, 2, 3, "15-06-2024 15:05:08"),
|
||||
Ranting(11, 4, 3, 2, "15-06-2024 15:05:12"),
|
||||
Ranting(12, 4, 4, 1, "15-06-2024 15:05:16")
|
||||
]
|
||||
9
analitics/Ranting.py
Normal file
9
analitics/Ranting.py
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
class Ranting:
|
||||
def __init__(self, id, movie_id, user_id, ranting, time):
|
||||
self.id=id
|
||||
self.movie_id=movie_id
|
||||
self.user_id=user_id
|
||||
self.ranting=ranting
|
||||
self.time=time
|
||||
33
analitics/RantingsAnalitics.py
Normal file
33
analitics/RantingsAnalitics.py
Normal file
@ -0,0 +1,33 @@
|
||||
from User import User
|
||||
from Ranting import Ranting
|
||||
from MockUps import users,rantings
|
||||
|
||||
|
||||
def get_rantings():
|
||||
return rantings
|
||||
|
||||
|
||||
def get_number_of_ratings():
|
||||
return get_rantings().__len__()
|
||||
|
||||
|
||||
def get_rantings_in_time(begin_time, end_time):
|
||||
pass
|
||||
|
||||
|
||||
def get_rantings_of_movie(movie_id):
|
||||
results = []
|
||||
for ranting in rantings:
|
||||
if ranting.movie_id == movie_id:
|
||||
results.append(ranting)
|
||||
return results
|
||||
|
||||
|
||||
def get_rantings_of_movie_numbers(movie_id):
|
||||
return get_rantings_of_movie(movie_id).__len__()
|
||||
|
||||
|
||||
def get_rantings_of_movie_in_time(movie_id, begin_time, end_time):
|
||||
pass
|
||||
|
||||
|
||||
7
analitics/User.py
Normal file
7
analitics/User.py
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
class User:
|
||||
def __init__(self,id,name):
|
||||
self.id=id
|
||||
self.name=name
|
||||
|
||||
|
||||
25
analitics/UserAnalitics.py
Normal file
25
analitics/UserAnalitics.py
Normal file
@ -0,0 +1,25 @@
|
||||
from User import User
|
||||
from Ranting import Ranting
|
||||
from MockUps import users,rantings
|
||||
|
||||
|
||||
def get_number_of_users():
|
||||
return users.__len__()
|
||||
|
||||
|
||||
def get_user_rantings(user_id):
|
||||
results=[]
|
||||
for ranting in rantings:
|
||||
if ranting.user_id==user_id:
|
||||
results.append(ranting)
|
||||
return results
|
||||
|
||||
|
||||
def get_user_rantings_number(user_id):
|
||||
return get_user_rantings(user_id).__len__()
|
||||
|
||||
|
||||
def get_user_rantings_in_time(user_id, begin, end):
|
||||
pass
|
||||
|
||||
|
||||
2
analitics/main.py
Normal file
2
analitics/main.py
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user