1

Okay, so I have created a ticket system for jobs at work.

There are three tables:

Job: id|subject|flag|status|deadline|ts

Team: id|jobID|userID|vocation

and exchange: id|details|foreignID|table|polyflag|userID|ts

Basically a job is created, inserted into job, the team is built up and inserted into team and any posts and conversation for this particular job is put into exchange.

But what I would like to do is find out if a user has not read any posts in a particular job. Because at the moment, they are having to actually go into the job page, and see if there is anything new in there they havent seen. If their job list is particularly large, this will become a problem.

So if a user posts something new, and they havent loaded the job and seen it, I want to be able to show them that somehow. The problem is I have no idea how I can do it.

Suggestions?

4

4 回答 4

0

使用 userID、postID 和 readStatus 创建另一个名为 readPostStatus 的表。

然后在帖子上,所有状态都将为读取状态。(有多种方法可以显示这些结果)

然后当特定用户阅读帖子时,编辑 readPostStatus 表,在 readStatus 中将 userID 和 postID 标记为 true

于 2013-07-24T11:47:26.510 回答
0

我认为您对作为工作团队成员的用户感兴趣,而不是创建工作的用户。另外我猜有一个用户表(其中userIDinTeam是外键)。

您本质上想要的是一个视图计数器,对于 each Userfor each Job。这对我来说看起来像是多对多的关系,在两张表之间。我建议这样做的最好方法是调用另一个表UserJob或者更有用的表,其中包含以下字段:jobIDuserIDviewCount。加载作业页面时,您运行查询以检查该表中是否已存在用于加载的作业的记录,由加载页面的用户执行。如果不是,则创建它(并将计数初始化为 1)。否则,您会增加查看次数。

如果您不关心计数,只关心它是否已被看到,那么您无需费心增加计数。您可能想命名字段hasSeen或其他名称,而不是viewCount.

hasSeen编辑:忘了说您可以通过查询此表并检查是否存在行(设置为1)轻松检查用户是否看过工作。根据您的结构,您可能希望hasSeen在将用户分配给作业时自动添加此表的行(设置为 0)。

于 2013-07-24T11:48:17.050 回答
0

您可以添加一个包含 user_id、job_id 列的新表,并且每次有人查看作业时您将其插入其中(仅第一次),因此您可以轻松地从该表中选择并查看用户查看了哪些作业或是否特定工作被用户看到

于 2013-07-24T11:44:07.810 回答
0

After seeing the answers on here I came up with my own solution, so just for the record, I will put it in here; as none of the other answers really cut it for me.

Okay. So my aversion from the other answers really stems from the fact that I didnt want to create another table. I hate clogging up my database with meaningless tables, and I wanted a better solution.

So I modifed the table team to:

Team: id|jobID|userID|vocation|exchangeID

Adding the column exchangeID, which basically stores the ID of the latest exchange that this user has read. This is updated everytime the user views a job. Easy enough.

Then to find out how many new posts, I simple grab a list from exchange of all the IDs relating to that job, and find out where in the list my team.exchangeID sits and then return the leftover rows gives me unread posts.

I have then stuck this code (20 lines long approx) into a setInterval that loads the data into a on the job view page, so that now that is automatically updated if anyone posts to a job without the person viewing! Smooth!

Thanks for all your help StackOverflow!

于 2013-07-24T15:29:46.087 回答