Coder Social home page Coder Social logo

Multiple reporters about phreeze HOT 5 OPEN

jasonhinkle avatar jasonhinkle commented on June 20, 2024
Multiple reporters

from phreeze.

Comments (5)

jasonhinkle avatar jasonhinkle commented on June 20, 2024

You sure can have as many reporters as you need. You just have to write the support code to go along with it.

Another option is you can create a MySQL "view" which Phreeze treats about the same as a table, but is read-only. If you haven't used views before, basically they are just a query that you write and MySQL saves it and treats it kinda like a table. The main advantage to using a view is that Phreeze Builder will generate the plumbing code for you.

from phreeze.

xtrasmal avatar xtrasmal commented on June 20, 2024

That's nice. I will read up on Views.

from phreeze.

xtrasmal avatar xtrasmal commented on June 20, 2024

Ok I have been playing around with MySQl and tried to get this View thing in my head.
These are the tables for the internal messaging system

CREATE TABLE IF NOT EXISTS `tb_messages` (
  `message_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `message_from` bigint(20) unsigned NOT NULL,
  `message_to` bigint(20) unsigned NOT NULL,
  `message_title` varchar(255) NOT NULL DEFAULT '',
  `message_content` longtext NOT NULL DEFAULT '',
  `message_date` timestamp,
  PRIMARY KEY (`message_id`),
  CONSTRAINT `sender` FOREIGN KEY (`message_from`) REFERENCES `tb_accounts` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `receiver` FOREIGN KEY (`message_to`) REFERENCES `tb_accounts` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tb_messageviewed` (
  `mv_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `message_id` bigint(20) unsigned NOT NULL,
  `account_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`mv_id`),
  CONSTRAINT `mv_message` FOREIGN KEY (`message_id`) REFERENCES `tb_messages` (`message_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `mv_account` FOREIGN KEY (`account_id`) REFERENCES `tb_accounts` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE  
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

These are the Views to show latest messages and the total new messages for the currentUser

CREATE OR REPLACE VIEW `view_new_msg` AS
  SELECT *
  FROM tb_messages t1
    WHERE NOT EXISTS (
    SELECT * 
    FROM tb_messageviewed t2
    WHERE t1.message_id LIKE t2.message_id ) + '%'

CREATE OR REPLACE VIEW `view_new_msg_total` AS
  SELECT message_to, COUNT(message_id) total_new
  FROM `view_new_msg`    
  GROUP BY message_to
  ORDER BY total_new DESC  

Will Phreeze understand the way I created the views?

from phreeze.

xtrasmal avatar xtrasmal commented on June 20, 2024

Yes it works really well

from phreeze.

jasonhinkle avatar jasonhinkle commented on June 20, 2024

awesome!

from phreeze.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.