Added some folders.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-11-25 22:40:17 +10:00
parent 50a3c94af8
commit a4b72664fd
13 changed files with 53 additions and 50 deletions

View File

@@ -0,0 +1,41 @@
using NeDvachAPI.DBControllers;
using NeDvachAPI.Models;
namespace NeDvachAPI.BufferControllers
{
public class APIThreadBuffer
{
private static List<Post> ThreadsPrewievs;
private static List<Post>[] Threads = new List<Post>[0];
public static void WriteThreadPreviewsBuffer(List<Post> OPPostsToWrite) //add list of OP-posts and last post to buffer
{
ThreadsPrewievs = OPPostsToWrite;
}
public static List<Post> GetThreadPreviews()
{
return ThreadsPrewievs;
}
public static void WriteThreadsBuffer(List<Post> ThreadToAdd) //add thread's posts from DB to buffer
{
Threads = Threads.Append(ThreadToAdd).ToArray();
}
public static List<Post> GetThread(int threadId)
{
if (threadId < Threads.Length + 1 & threadId != 0)
{
;
return Threads[threadId - 1];
}
else return null;
}
public static void RefreshThread(int threadId)
{
Threads[threadId - 1] = DBchat.PostsList("b", threadId);
}
}
}

View File

@@ -0,0 +1,23 @@
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> posts = DBchat.ThreadsList(board);
APIThreadBuffer.WriteThreadPreviewsBuffer(posts);
Console.WriteLine("Заполняю буфер оп-постами");
for (int threadId = 1; threadId <= 4; threadId++)
{
APIThreadBuffer.WriteThreadsBuffer(DBchat.PostsList(board, threadId));
Console.WriteLine("Добавляю буферизую тред " + threadId);
}
return true;
}
}
}