Welcome Guest, Not a member yet? Register   Sign In
one problem with a queue system...
#1

[eluser]emily12[/eluser]
So I'm building a queue system where you can see a list of articles and a little queue button. It works fine but if the entry already exists, regardless of the user, it picks that one so it will act as if it is already queued even if it isn't.

In my model I have it to where everything joins in perfectly well (5 joins because of the complexity of everything) and it groups it by the article since that's what you're viewing is a list of articles.

In the view I check to see if the database entry for queued matches the ID and if it doesn't then you can queue it if you like. Well, the obvious problem happens here and it grabs the first result of the queued item in the database and shows that it's been queued if someone queued that specific article. Note that you can queue every article up to one time for all members at this point).

What should I do in order to query the queue table for that user id?


Model looks like this:
Code:
$this->db->select('*'); // Edited for ease of view
$this->db->from ('viewcounter AS b');
$this->db->join('articles AS p', 'p.articleid = b.id', 'left');
$this->db->join('phpbb_users AS d', 'p.author = d.user_id', 'left');
$this->db->join('categories AS c', 'c.id = p.subcat', 'left');
$this->db->join('queue AS f', 'f.queueaid = p.articleid', 'left');
$this->db->join('queue_type AS g', 'g.queuebitid = f.queuecat', 'left');
$this->db->where('p.subcategory >=', 27);
$this->db->where('p.subcategory <=', 45);
$this->db->group_by("b.id");
$this->db->order_by('b.views', "desc");
$this->db->limit($limit);
  
$query = $this->db->get();
return $query;

The column in question is queueuid (userid value) which is found in queue.

Thank you!


NOTES:
+ Adding "bookmark queue" to the database works fine
+ Each article has their own id which can be queued, works fine
+ User ID is fetched properly
- Each article as a result looks only for the first result if it even exists for the queue table. This needs to be for all of it.
#2

[eluser]gRoberts[/eluser]
When you Queue an article, what happens once it's queued and then "processed"?

Really, once something is queued, you will then process it and once processed, either remove it, or mark it as processed. This way, you can filter the "processed" items out of the query, leaving only queued items.

Also, if it's "user" dependant, you will need to alter your query so it only returns queued items for that user, rather than just everything. If you want to prevent people from queuing something when someone already has, then your code as is (with exception to the above comments) is fine, as this prevents you from queuing it again.

HTH
#3

[eluser]emily12[/eluser]
Thank you, it is "user" dependent, and that is the question in hand. I have absolutely no idea how to change the query so it works independently for each user. Try as I might, logically I can't figure this one out. =/




Theme © iAndrew 2016 - Forum software by © MyBB