Skip to content

Conversation

@lokiplot
Copy link
Owner

это для ревью

lpetrov02 and others added 12 commits November 27, 2020 23:11
умеет на >1000, быстро работает
Renamed functions and added working with a period
ahahahaha tokeni na githube ne hraniatsia hahahah
Renamed functions and added working with a period
Написал бота. Понимает некоторые штуки, но суть такова: получает формат: "group_id: .....; period: .....", пробелы важны. Возвращает процент онлайн - разово. Вырубается по команде stop
upgraded bot
Copy link
Contributor

@lpetrov02 lpetrov02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Короче добавь докстринги и немного больше комментируй происходящее, а то не всегда понятно.

import matplotlib.dates as mdates


dict_with_data = {datetime.datetime(2020, 12, 7, 1): 53,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не очень понятно, что это за циферки

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Которыми ты заполняешь dict_with_data

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если это просто чиселки для тестинга, то наверно лучше коммент поставить

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да, оно не надо ни для чего, закомменчу

return
day_of_week = [0, 1, 2, 3, 4, 5, 6]
online_on_this_weekday = [0, 0, 0, 0, 0, 0, 0]
for date in dict_with_data:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не очень понимаю здесь: ты бегаешь переменной date по dict_with_data, а потом итерируешься по date...

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

date -- ключи в словаре, цикл нужен для того, чтобы узнать дельту данных. я просто не в курсе, как просто посмотреть разницу между соседними ячейками словаря

for date in dict_with_data:
online_on_this_weekday[date.weekday()] = dict_with_data[date]
labels = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
pltt.rcParams['figure.figsize'] = 7, 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наверное был бы неплох коммент, где ты разъясняешь, что значат эти слова. Оно наверное понятно и так, но нужно ведь наверняка

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну это просто оформление и всякие параметры картинки. так и напишу

day_delta = 0
prev_key = datetime.datetime.now()
for key in dict_with_data:
day_delta = key - prev_key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему нельзя сразу в конец списка рассмотреть?
data_length = len(dict_with_data)
day_delta = dict_with_data[data_length - 1] - dict_with_data[data_length - 2]
Ну там ещё можно проверку на слишком короткий массив.
Просто суть в том, что ты меняешь значение переменной в цикле, при этом промежуточные никуда не складываешь.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

потому что из data_length - 1 -- не ключ словаря. ну промежуточные и правда не нужны, но это такой костыль, чтобы коротко написать

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну смотри...

for key in dict_with_data:
y_axis[int((key.minute + key.hour * 60) // period)] = dict_with_data[key]
figure, ax = plt.subplots(figsize=(number_of_dots, 10))
ax.set_title(label_of_image)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Коротенькие комментарии напиши, наверное, что какой мини-блок делает

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кок

figure.savefig("images/" + label_of_image + ".png")


def create_graph_image(period, total_time, y_axis, label_of_graph):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично - комментики. И докстринги кстати!!!

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кок

month_length = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]


def upload_picture(picture_path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Комментарии и докстринг

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кок

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants