This repository has been archived on 2023-06-30. You can view files and clone it, but cannot push or open issues or pull requests.
2chBackAPI/BufferControllers/BufferFill.cs
RakVhalate 5bc7cceb5b
All checks were successful
continuous-integration/drone/push Build is passing
148
2023-01-29 22:58:53 +10:00

34 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using NeDvachAPI.DBControllers;
using NeDvachAPI.Models;
namespace NeDvachAPI.BufferControllers
{
public class BufferFill
{
public static bool FillBuffer(string board) //method to get buffer of information, which is being ran while API is started
{
List<Post> Previews = DBchat.ThreadsList(board);
APIThreadBuffer.WriteThreadPreviewsBuffer(Previews);
Console.WriteLine("Заполняю буфер оп-постами " + Previews.Count);
for (int threadId = 1; threadId <= Previews.Count; threadId++)
{
APIThreadBuffer.AppendThreadsBuffer(DBchat.PostsList(board, threadId));
}
Console.WriteLine($@"Буферизую треды с {1} по {Previews.Count}.");
for (int preview = 0; preview < Previews.Count; preview++)
{
int targetLength = APIThreadBuffer.GetThreadLength(preview);
for (int lastofthree = targetLength- 2; lastofthree <= targetLength; lastofthree ++)
{
APIThreadBuffer.AppendToThreadPreviews(preview,APIThreadBuffer.GetSinglePost(preview,lastofthree));
}
}
return true;
}
}
}