code_junkie

Is there an agreed ideal schema for tagging

Nov 11th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. photos
  2. photoid
  3. caption
  4. filename
  5. date
  6.  
  7. tags
  8. tagid
  9. tagname
  10.  
  11. phototags
  12. photoid
  13. tagid
  14.  
  15. public static void threadproc_tags(object obj)
  16. {
  17. System.Web.HttpApplicationState app = (System.Web.HttpApplicationState)obj;
  18.  
  19. SortedDictionary<string,List<int>> tags = new SortedDictionary<string,List<int>>();
  20.  
  21. // update the cache
  22. DbUtil dbutil = new DbUtil();
  23. DataSet ds = dbutil.get_dataset("select bg_id, bg_tags from bugs where isnull(bg_tags,'') <> ''");
  24.  
  25. foreach (DataRow dr in ds.Tables[0].Rows)
  26. {
  27. string[] labels = btnet.Util.split_string_using_commas((string) dr[1]);
  28.  
  29. // for each tag label, build a list of bugids that have that label
  30. for (int i = 0; i < labels.Length; i++)
  31. {
  32.  
  33. string label = normalize_tag(labels[i]);
  34.  
  35. if (label != "")
  36. {
  37. if (!tags.ContainsKey(label))
  38. {
  39. tags[label] = new List<int>();
  40. }
  41.  
  42. tags[label].Add((int)dr[0]);
  43. }
  44. }
  45. }
  46.  
  47. app["tags"] = tags;
  48.  
  49. }
Add Comment
Please, Sign In to add comment