F
F
Floydreme2018-09-25 15:54:32
JavaScript
Floydreme, 2018-09-25 15:54:32

How to count the number of posts per day for an individual?

There is a certain command by which a person can find out how many posts he made in a certain list of groups per day. The problem is that for each command call, you can get a maximum of 100 posts (this is not enough, entries appear every second). As a result, if a person has conditionally made 20 posts, this hundred has accumulated, some time has passed, the person decides to check the number of posts made and will see 0, since a new hundred has come out, and the old one has disappeared. How to make sure that the statistics are saved? I understand that when the command is called, everything is reset to zero, but still. Do not offer the option with the database, please.
Thanks in advance
Here is the code:

var allUsers = []
var userInfo = []

updates.hear('/имя_команды', async(context) => {
//Узнаем имя человека, который обратился к команде
const [userName] = await api.users.get({
  user_ids: context.senderId,
  name_case: 'nom'
});
const Groups = new Array(8)
Groups[0] = await api.wall.get({
  domain: `1`,
  count: 100,
  extended: true,
  filter: 'others'
})
Groups[1] = await api.wall.get({
  domain: `2`,
  count: 100,
  extended: true,
  filter: 'others'
})
Groups[2] = await api.wall.get({
  domain: `3`,
  count: 100,
  extended: true,
  filter: 'others'
})
Groups[3] = await api.wall.get({
  owner_id: 4,
  count: 100,
  extended: true,
  filter: 'others'
}) 
Groups[4] = await api.wall.get({
  owner_id: 5,
  count: 100,
  extended: true,
  filter: 'others'
})
Groups[5] = await api.wall.get({
  owner_id: 6,
  count: 100,
  extended: true,
  filter: 'others'
})
Groups[6] = await api.wall.get({
  domain: `7`,
  count: 100,
  extended: true,
  filter: 'others'
})
Groups[7] = await api.wall.get({
  domain: `8`,
  count: 100,
  extended: true,
  filter: 'others'
})

var k = 0
for(var i = 0; i < Groups.length; i++)
{
  for(var j = 0; j < Groups[i].items.length; j++)
  {
    userInfo[k] = Groups[i].items[j].from_id
    k++
  }	
}
allUsers.push(userInfo)
console.log(userInfo)
console.log(allUsers)
for(var i = 0; i < userInfo.length; i++)
{
  if(userInfo[i] === context.senderId)
  {
    count++
  }	
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2018-09-25
@FloydReme

when the command is called, everything is reset to zero, but still

But what? Why don't you want to use a database or other storage?
One way or another, you need to save idthe most recent verified post on each of the walls. To then check up to it, if necessary, checking deeper than 100 posts.
  • can check deeper than the last 100 posts by specifying the offset parameter
  • you can “pack” up to 25 calls to the VK API into one execute() request , then you can execute not 3 but 75 requests per second
  • as storage, you can use not a local database, but VKontaktovsky storage .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question