Skip to main content

Flags (new and updated tags)

On the projects screen, you may see flags like “new” or “updated” against projects, assets or files: Updated flag There is a database table catalog_flags (API class CatalogFlags. Anything older than its expires field is automatically removed. The flags are set from the Events model:
 ___________       ___________       _____________
|           |     |           |     |             |
| Something |  \  |   Event   |  \  |  Catalog::  |
|  happens  |  /  | generated |  /  | updateFlags |
|           |     |           |     |  triggered  |
|___________|     |___________|     |_____________|
updateFlags is supplied an event and a list of users. It then upserts (creates or updates) that flag per-user. The CatalogFlags determines whether an event is a project, asset, or file level flag by extracting that information from the event in the collect() function. The UI inspects project.$flags (an array of strings, generally empty if nothing is new/updated) to determine whether to display flags. To do anything with flags, an event has to:
  1. Be triggered by something - i.e. have a rule - you can see a list of rules in Events::$_rules.
  2. Have a collector in the CatalogFlags::collect() function.
  3. Have one or more users returned from the Events::__users() function
  4. Each matching user gets a flag set. If not users match, no flags set.

Serving flags to the user

There is a Flags proxy. If a controller wants to embed flags, it can do something like:
class Projects extends Base {
	protected $_proxies = [
		// ...
		'Flags'  => ['project'],
		// ...
	];
This tells it what to check for - project for project flags, file for file flags, etc.

Troubleshooting

We have historically had many issues with this system. Places to look:
  1. Are flags being set by events?
  2. Are the flags set for all the users they are supposed to be?
  3. Have users somehow cleared flags?
  4. I don’t think they can do this, but…
  5. Is an event being created?
  6. At the time of writing, there is no event for project update, for example, in Events::$_rules
  7. Is there a collector in CatalogFlags::collect() function for the event?
  8. Maybe if there are more than X users it fails?
  9. When the events are created, is the date being set correctly?
  10. See the mongo docs on expireAfterSeconds

Specific test scripts

Testing asset updates (Events::ASSET_UPDATE)

TODO how in the heck does this work?????!!!!
Back to docs index | Next page in recommended reading order >>