<commit_before><?php namespace DMA\Friends\Updates;

use DB;
use October\Rain\Database\Updates\Migration;

class CreateActivityView extends Migration {

    /** 
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {   
        DB::statement('CREATE VIEW dma_friends_activity_stream AS

            CREATE 
                ALGORITHM = UNDEFINED 
                DEFINER = `root`@`localhost` 
                SQL SECURITY DEFINER
            VIEW `dma_friends_activity_stream` AS
                select 
                    `a`.`title` AS `title`,
                    `pivot`.`activity_id` AS `object_id`,
                    `pivot`.`created_at` AS `created_at`,
                    `pivot`.`user_id` AS `user_id`,
                    'Activity' COLLATE utf8_unicode_ci AS `object_type` 
                from
                    (`dma_friends_activity_user` `pivot`
                    left join `dma_friends_activities` `a` ON ((`pivot`.`activity_id` = `a`.`id`))) 
                union select 
                    `a`.`title` AS `title`,
                    `pivot`.`badge_id` AS `object_id`,
                    `pivot`.`created_at` AS `created_at`,
                    `pivot`.`user_id` AS `user_id`,
                    'Badge' COLLATE utf8_unicode_ci AS `object_type`
                from
                    (`dma_friends_badge_user` `pivot`
                    left join `dma_friends_badges` `a` ON ((`pivot`.`badge_id` = `a`.`id`))) 
                union select 
                    `a`.`title` AS `title`,
                    `pivot`.`reward_id` AS `id`,
                    `pivot`.`created_at` AS `created_at`,
                    `pivot`.`user_id` AS `user_id`,
                    'Reward' COLLATE utf8_unicode_ci AS `object_type`
                from
                    (`dma_friends_reward_user` `pivot`
                    left join `dma_friends_rewards` `a` ON ((`pivot`.`reward_id` = `a`.`id`))) 
                union select 
                    `a`.`title` AS `title`,
                    `pivot`.`step_id` AS `object_id`,
                    `pivot`.`created_at` AS `created_at`,
                    `pivot`.`user_id` AS `user_id`,
                    'Step' COLLATE utf8_unicode_ci AS `object_type`
                from
                    (`dma_friends_step_user` `pivot`
                    left join `dma_friends_steps` `a` ON ((`pivot`.`step_id` = `a`.`id`)))
                order by `created_at` desc
        ');<commit_msg>Fixed activity_stream view query creation.  - Replaced single quotes with double quotes when required.  - Removed double Create statement.<commit_after><?php namespace DMA\Friends\Updates;

use DB;
use October\Rain\Database\Updates\Migration;

class CreateActivityView extends Migration {

    /** 
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {   
        DB::statement('CREATE VIEW dma_friends_activity_stream AS
                select 
                    `a`.`title` AS `title`,
                    `pivot`.`activity_id` AS `object_id`,
                    `pivot`.`created_at` AS `created_at`,
                    `pivot`.`user_id` AS `user_id`,
                    "Activity" COLLATE utf8_unicode_ci AS `object_type` 
                from
                    (`dma_friends_activity_user` `pivot`
                    left join `dma_friends_activities` `a` ON ((`pivot`.`activity_id` = `a`.`id`))) 
                union select 
                    `a`.`title` AS `title`,
                    `pivot`.`badge_id` AS `object_id`,
                    `pivot`.`created_at` AS `created_at`,
                    `pivot`.`user_id` AS `user_id`,
                    "Badge" COLLATE utf8_unicode_ci AS `object_type`
                from
                    (`dma_friends_badge_user` `pivot`
                    left join `dma_friends_badges` `a` ON ((`pivot`.`badge_id` = `a`.`id`))) 
                union select 
                    `a`.`title` AS `title`,
                    `pivot`.`reward_id` AS `id`,
                    `pivot`.`created_at` AS `created_at`,
                    `pivot`.`user_id` AS `user_id`,
                    "Reward" COLLATE utf8_unicode_ci AS `object_type`
                from
                    (`dma_friends_reward_user` `pivot`
                    left join `dma_friends_rewards` `a` ON ((`pivot`.`reward_id` = `a`.`id`))) 
                union select 
                    `a`.`title` AS `title`,
                    `pivot`.`step_id` AS `object_id`,
                    `pivot`.`created_at` AS `created_at`,
                    `pivot`.`user_id` AS `user_id`,
                    "Step" COLLATE utf8_unicode_ci AS `object_type`
                from
                    (`dma_friends_step_user` `pivot`
                    left join `dma_friends_steps` `a` ON ((`pivot`.`step_id` = `a`.`id`)))
                order by `created_at` desc
        ');
{'fraction_non_alphanumeric': 0.11707317073170732, 'fraction_numerical': 0.0016260162601626016, 'mean_word_length': 1.4349332013854528, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6938516', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1416, 'n_words': 311}