appraisal | Ruby library for testing your library | Continous Integration library

 by   thoughtbot Ruby Version: v2.4.1 License: MIT

kandi X-RAY | appraisal Summary

appraisal is a Ruby library typically used in Devops, Continous Integration, Ruby On Rails applications. appraisal has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.
[Build Status][Build Status Image]][Build Status]. Find out what your Ruby gems are worth. [Build Status Image]: [Build Status]:
    Support
      Quality
        Security
          License
            Reuse
            Support
              Quality
                Security
                  License
                    Reuse

                      kandi-support Support

                        summary
                        appraisal has a medium active ecosystem.
                        summary
                        It has 1175 star(s) with 103 fork(s). There are 45 watchers for this library.
                        summary
                        It had no major release in the last 12 months.
                        summary
                        There are 10 open issues and 104 have been closed. On average issues are closed in 346 days. There are 1 open pull requests and 0 closed requests.
                        summary
                        It has a neutral sentiment in the developer community.
                        summary
                        The latest version of appraisal is v2.4.1
                        appraisal Support
                          Best in #Continous Integration
                            Average in #Continous Integration
                            appraisal Support
                              Best in #Continous Integration
                                Average in #Continous Integration

                                  kandi-Quality Quality

                                    summary
                                    appraisal has 0 bugs and 0 code smells.
                                    appraisal Quality
                                      Best in #Continous Integration
                                        Average in #Continous Integration
                                        appraisal Quality
                                          Best in #Continous Integration
                                            Average in #Continous Integration

                                              kandi-Security Security

                                                summary
                                                appraisal has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
                                                summary
                                                appraisal code analysis shows 0 unresolved vulnerabilities.
                                                summary
                                                There are 0 security hotspots that need review.
                                                appraisal Security
                                                  Best in #Continous Integration
                                                    Average in #Continous Integration
                                                    appraisal Security
                                                      Best in #Continous Integration
                                                        Average in #Continous Integration

                                                          kandi-License License

                                                            summary
                                                            appraisal is licensed under the MIT License. This license is Permissive.
                                                            summary
                                                            Permissive licenses have the least restrictions, and you can use them in most projects.
                                                            appraisal License
                                                              Best in #Continous Integration
                                                                Average in #Continous Integration
                                                                appraisal License
                                                                  Best in #Continous Integration
                                                                    Average in #Continous Integration

                                                                      kandi-Reuse Reuse

                                                                        summary
                                                                        appraisal releases are available to install and integrate.
                                                                        summary
                                                                        Installation instructions, examples and code snippets are available.
                                                                        summary
                                                                        appraisal saves you 1073 person hours of effort in developing the same functionality from scratch.
                                                                        summary
                                                                        It has 2463 lines of code, 161 functions and 44 files.
                                                                        summary
                                                                        It has medium code complexity. Code complexity directly impacts maintainability of the code.
                                                                        appraisal Reuse
                                                                          Best in #Continous Integration
                                                                            Average in #Continous Integration
                                                                            appraisal Reuse
                                                                              Best in #Continous Integration
                                                                                Average in #Continous Integration
                                                                                  Top functions reviewed by kandi - BETA
                                                                                  kandi has reviewed appraisal and discovered the below as its top functions. This is intended to give you an instant insight into appraisal implemented functionality, and help decide if they suit your requirements.
                                                                                  • Build the options of the Bundler
                                                                                    • Make sure the Bundler gem is installed
                                                                                      • Installs the library .
                                                                                        • Returns a hash containing the paths in the specified paths .
                                                                                          • Run a command in the environment .
                                                                                            • Allows you to call an individual .
                                                                                              • Substitute a hash with the provided sources
                                                                                                • Adds a source to the source
                                                                                                  • Create a new repository
                                                                                                    • Installs the document .
                                                                                                      Get all kandi verified functions for this library.
                                                                                                      Get all kandi verified functions for this library.

                                                                                                      appraisal Key Features

                                                                                                      A Ruby library for testing your library against different versions of dependencies.

                                                                                                      appraisal Examples and Code Snippets

                                                                                                      No Code Snippets are available at this moment for appraisal.
                                                                                                      Community Discussions

                                                                                                      Trending Discussions on appraisal

                                                                                                      Issue in creating recursive JSON hierarchy tree
                                                                                                      chevron right
                                                                                                      when i add record, how can i insert value of foreign key in Sequelize
                                                                                                      chevron right
                                                                                                      How to write url for testing when using viewsets in Django Restframework
                                                                                                      chevron right
                                                                                                      AttributeError: 'WebElement' object has no attribute 'Click' error trying to Click on a link using Selenium Python
                                                                                                      chevron right
                                                                                                      Remove all punctuation from string
                                                                                                      chevron right
                                                                                                      Handle uncompleted file upload by API POST endpoint in asp.net core MVC
                                                                                                      chevron right
                                                                                                      How to access SSM Parameter Store from SAM lambda local in node
                                                                                                      chevron right
                                                                                                      HTML place divs on same level
                                                                                                      chevron right
                                                                                                      How can I listen for a Service variable change in a component in Angular
                                                                                                      chevron right
                                                                                                      How do I load nested entities in entity framework when they cross reference each other?
                                                                                                      chevron right

                                                                                                      QUESTION

                                                                                                      Issue in creating recursive JSON hierarchy tree
                                                                                                      Asked 2022-Mar-10 at 20:55

                                                                                                      I have input data in flatfile format. I have written my javascript code to create recursive hierarchy JSON tree. I am not getting expected tree (highlighted below as expected output). Can anyone please help me understand where I might be going wrong?

                                                                                                      Note: In input data if there is no child_id it means it is leaf node.

                                                                                                      Input data with code

                                                                                                      var data=[
                                                                                                               {"Type":"Root","url":"abc","description":"Enterprise Risk Management Framework","id":0,"child_id":3},
                                                                                                      
                                                                                                      {"Type":"Stem","url":"def","description":"Risk Governance Framework","id":3,"child_id":4},
                                                                                                      
                                                                                                      {"Type":"Stem","url":"def","description":"Risk Governance Framework","id":3,"child_id":9},
                                                                                                      
                                                                                                      {"Type":"Stem","url":"def","description":"Risk Governance Framework","id":3,"child_id":11},
                                                                                                      
                                                                                                      {"Type":"Stem","url":"ghi","description":"Wholesale Credit Risk framework","id":4,"child_id":6},
                                                                                                      
                                                                                                      {"Type":"Stem","url":"jkl","description":"Wholesale Credit Risk Policy","id":6,"child_id":7},
                                                                                                      
                                                                                                      {"Type":"Stem","url":"jkl","description":"Wholesale Credit Risk Policy","id":6,"child_id":8},
                                                                                                      
                                                                                                      {"Type":"Leaf","url":"mno","description":"Wholesale Credit In-Business Quality Assurance Standard","id":7},
                                                                                                      
                                                                                                      {"Type":"Leaf","url":"pqr","description":"WCR Exception Management Standard","id":8},
                                                                                                      
                                                                                                      {"Type":"Stem","url":"stu","description":"Global Collateral Management Policy","id":9,"child_id":10},
                                                                                                      
                                                                                                      {"Type":"Leaf","url":"gov","description":"WCR Collateral Management Standard","id":10},
                                                                                                      
                                                                                                      {"Type":"Stem","url":"iit","description":"Real Estate Appraisal and Valuation Policy","id":11,"child_id":12},
                                                                                                      
                                                                                                      {"Type":"Stem","url":"iim","description":"Commercial Real Estate Appraisal/Valuation Standard","id":12,"child_id":13},
                                                                                                      
                                                                                                      {"Type":"Leaf","url":"har","description":"Commercial Real Estate Appraisal/Valuation Procedures","id":13}
                                                                                                              ]
                                                                                                      
                                                                                                      
                                                                                                      
                                                                                                      // Given a parent ID, find and return the item in the data with that ID
                                                                                                      const findParent = parentId => data.find(item => item.child_id === parentId)
                                                                                                      
                                                                                                      // Create the tree by reducing the data to a root list
                                                                                                      // that only contains "orphans". Items that do have a
                                                                                                      // parent will be appended to those orphans' child lists
                                                                                                      // instead
                                                                                                      const tree = data.reduce((root, item) => {
                                                                                                        // Find the parent of the current item
                                                                                                        const parent = findParent(item.id)
                                                                                                      
                                                                                                        if (parent) {
                                                                                                          // If a parent was found, append the current item
                                                                                                          // to the parent's child list. Since objects are
                                                                                                          // passed by reference, it doesn't matter whether 
                                                                                                          // the parent is already in the root list  or not 
                                                                                                          // -- it always points to the same object
                                                                                                          parent.children = parent.children || []
                                                                                                          parent.children.push(item)
                                                                                                        } else {
                                                                                                          // Otherwise push the item to the root list
                                                                                                          root.push(item)
                                                                                                        }
                                                                                                      
                                                                                                        return root
                                                                                                      }, [])
                                                                                                      
                                                                                                      console.log(JSON.stringify(tree));

                                                                                                      Current Output

                                                                                                      [
                                                                                                        {
                                                                                                          "Type": "Root",
                                                                                                          "url": "abc",
                                                                                                          "description": "Enterprise Risk Management Framework",
                                                                                                          "id": 0,
                                                                                                          "child_id": 3,
                                                                                                          "children": [
                                                                                                            {
                                                                                                              "Type": "Stem",
                                                                                                              "url": "def",
                                                                                                              "description": "Risk Governance Framework",
                                                                                                              "id": 3,
                                                                                                              "child_id": 4,
                                                                                                              "children": [
                                                                                                                {
                                                                                                                  "Type": "Stem",
                                                                                                                  "url": "mno",
                                                                                                                  "description": "Wholesale Credit Risk Framework",
                                                                                                                  "id": 4,
                                                                                                                  "child_id": 6,
                                                                                                                  "children": [
                                                                                                                    {
                                                                                                                      "Type": "Stem",
                                                                                                                      "url": "pqr",
                                                                                                                      "description": "Wholesale Credit Risk Policy",
                                                                                                                      "id": 6,
                                                                                                                      "child_id": 7,
                                                                                                                      "children": [
                                                                                                                        {
                                                                                                                          "Type": "Leaf",
                                                                                                                          "url": "vwx",
                                                                                                                          "description": "Wholesale Credit In-Business Quality Assurance Standard",
                                                                                                                          "id": 7
                                                                                                                        }
                                                                                                                      ]
                                                                                                                    },
                                                                                                                    {
                                                                                                                      "Type": "Stem",
                                                                                                                      "url": "stu",
                                                                                                                      "description": "Wholesale Credit Risk Policy",
                                                                                                                      "id": 6,
                                                                                                                      "child_id": 8,
                                                                                                                      "children": [
                                                                                                                        {
                                                                                                                          "Type": "Leaf",
                                                                                                                          "url": "zab",
                                                                                                                          "description": "WCR Exception Management Standard",
                                                                                                                          "id": 8
                                                                                                                        }
                                                                                                                      ]
                                                                                                                    }
                                                                                                                  ]
                                                                                                                }
                                                                                                              ]
                                                                                                            },
                                                                                                            {
                                                                                                              "Type": "Stem",
                                                                                                              "url": "ghi",
                                                                                                              "description": "Risk Governance Framework",
                                                                                                              "id": 3,
                                                                                                              "child_id": 9,
                                                                                                              "children": [
                                                                                                                {
                                                                                                                  "Type": "Stem",
                                                                                                                  "url": "nsr",
                                                                                                                  "description": "Global Collateral Management Policy",
                                                                                                                  "id": 9,
                                                                                                                  "child_id": 10,
                                                                                                                  "children": [
                                                                                                                    {
                                                                                                                      "Type": "Leaf",
                                                                                                                      "url": "gov",
                                                                                                                      "description": "WCR Collateral Management Standard",
                                                                                                                      "id": 10
                                                                                                                    }
                                                                                                                  ]
                                                                                                                }
                                                                                                              ]
                                                                                                            },
                                                                                                            {
                                                                                                              "Type": "Stem",
                                                                                                              "url": "jkl",
                                                                                                              "description": "Risk Governance Framework",
                                                                                                              "id": 3,
                                                                                                              "child_id": 11,
                                                                                                              "children": [
                                                                                                                {
                                                                                                                  "Type": "Stem",
                                                                                                                  "url": "iit",
                                                                                                                  "description": "Real Estate Appraisal and Valuation Policy",
                                                                                                                  "id": 11,
                                                                                                                  "child_id": 12,
                                                                                                                  "children": [
                                                                                                                    {
                                                                                                                      "Type": "Stem",
                                                                                                                      "url": "iim",
                                                                                                                      "description": "Commercial Real Estate Appraisal/Valuation Standard",
                                                                                                                      "id": 12,
                                                                                                                      "child_id": 13,
                                                                                                                      "children": [
                                                                                                                        {
                                                                                                                          "Type": "Leaf",
                                                                                                                          "url": "har",
                                                                                                                          "description": "Commercial Real Estate Appraisal/Valuation Procedures",
                                                                                                                          "id": 13
                                                                                                                        }
                                                                                                                      ]
                                                                                                                    }
                                                                                                                  ]
                                                                                                                }
                                                                                                              ]
                                                                                                            }
                                                                                                          ]
                                                                                                        }
                                                                                                      ]
                                                                                                      

                                                                                                      expected Output

                                                                                                      {
                                                                                                        "id": 0,
                                                                                                        "type": "Root",
                                                                                                        "description": "Enterprise Risk Management Framework",
                                                                                                        "url": "abc",
                                                                                                        "children": [
                                                                                                          {
                                                                                                            "id": 3,
                                                                                                            "type": "Stem",
                                                                                                            "description": "Risk Governance Framework",
                                                                                                            "url": "def",
                                                                                                            "children": [
                                                                                                              {
                                                                                                                "id": 4,
                                                                                                                "type": "Stem",
                                                                                                                "description": "Wholesale Credit Risk Framework",
                                                                                                                "url": "ghi",
                                                                                                                "children": [
                                                                                                                  {
                                                                                                                    "id": 6,
                                                                                                                    "type": "Stem",
                                                                                                                    "description": "Wholesale Credit Risk Policy",
                                                                                                                    "url": "jkl",
                                                                                                                    "children": [
                                                                                                                      {
                                                                                                                        "id": 7,
                                                                                                                        "type": "Leaf",
                                                                                                                        "description": "Wholesale Credit In-Business Quality Assurance Standard",
                                                                                                                        "url": "mno",
                                                                                                                        "children": [
                                                                                                                          
                                                                                                                        ]
                                                                                                                      },
                                                                                                                      {
                                                                                                                        "id": 8,
                                                                                                                        "type": "Leaf",
                                                                                                                        "description": "WCR Exception Management Standard",
                                                                                                                        "url": "pqr",
                                                                                                                        "children": [
                                                                                                                          
                                                                                                                        ]
                                                                                                                      }
                                                                                                                    ]
                                                                                                                  }
                                                                                                                ]
                                                                                                              },
                                                                                                              {
                                                                                                                "id": 9,
                                                                                                                "type": "Stem",
                                                                                                                "description": "Global Collateral Management Policy",
                                                                                                                "url": "stu",
                                                                                                                "children": [
                                                                                                                  {
                                                                                                                    "id": 10,
                                                                                                                    "type": "Leaf",
                                                                                                                    "description": "WCR Collateral Management Standard",
                                                                                                                    "url": "gov",
                                                                                                                    "children": [
                                                                                                                      
                                                                                                                    ]
                                                                                                                  }
                                                                                                                ]
                                                                                                              },
                                                                                                              {
                                                                                                                "id": 11,
                                                                                                                "type": "Stem",
                                                                                                                "description": "Real Estate Appraisal and Valuation Policy",
                                                                                                                "url": "iit",
                                                                                                                "children": [
                                                                                                                  {
                                                                                                                    "id": 12,
                                                                                                                    "type": "Stem",
                                                                                                                    "description": "Commercial Real Estate Appraisal/Valuation Standard",
                                                                                                                    "url": "iim",
                                                                                                                    "children": [
                                                                                                                      {
                                                                                                                        "id": 13,
                                                                                                                        "type": "Leaf",
                                                                                                                        "description": "Commercial Real Estate Appraisal/Valuation Procedures",
                                                                                                                        "url": "har",
                                                                                                                        "children": [
                                                                                                                          
                                                                                                                        ]
                                                                                                                      }
                                                                                                                    ]
                                                                                                                  }
                                                                                                                ]
                                                                                                              }
                                                                                                            ]
                                                                                                          }
                                                                                                        ]
                                                                                                      }
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2022-Mar-10 at 20:55

                                                                                                      You could collect the id and corresponding target object in a Map. Initially the children property of each object will be empty. Then iterate the data again to lookup the object for a given id and the object for the given child_id and put the latter object into the children array of the former. Finally, get the root object which is assumed to have id 0.

                                                                                                      Code:

                                                                                                      const data = [{"Type":"Root","url":"abc","description":"Enterprise Risk Management Framework","id":0,"child_id":3},{"Type":"Stem","url":"def","description":"Risk Governance Framework","id":3,"child_id":4},{"Type":"Stem","url":"def","description":"Risk Governance Framework","id":3,"child_id":9},{"Type":"Stem","url":"def","description":"Risk Governance Framework","id":3,"child_id":11},{"Type":"Stem","url":"ghi","description":"Wholesale Credit Risk framework","id":4,"child_id":6},{"Type":"Stem","url":"jkl","description":"Wholesale Credit Risk Policy","id":6,"child_id":7},{"Type":"Stem","url":"jkl","description":"Wholesale Credit Risk Policy","id":6,"child_id":8},{"Type":"Leaf","url":"mno","description":"Wholesale Credit In-Business Quality Assurance Standard","id":7},{"Type":"Leaf","url":"pqr","description":"WCR Exception Management Standard","id":8},{"Type":"Stem","url":"stu","description":"Global Collateral Management Policy","id":9,"child_id":10},{"Type":"Leaf","url":"gov","description":"WCR Collateral Management Standard","id":10},{"Type":"Stem","url":"iit","description":"Real Estate Appraisal and Valuation Policy","id":11,"child_id":12},{"Type":"Stem","url":"iim","description":"Commercial Real Estate Appraisal/Valuation Standard","id":12,"child_id":13},{"Type":"Leaf","url":"har","description":"Commercial Real Estate Appraisal/Valuation Procedures","id":13}];
                                                                                                      
                                                                                                      const map = new Map(data.map(({child_id, ...rest}) => [rest.id, {...rest, children: []}]));
                                                                                                      
                                                                                                      for (const {id, child_id} of data) {
                                                                                                          if (child_id) map.get(id).children.push(map.get(child_id));
                                                                                                      }
                                                                                                      
                                                                                                      console.log(map.get(0));

                                                                                                      Source https://stackoverflow.com/questions/71429713

                                                                                                      QUESTION

                                                                                                      when i add record, how can i insert value of foreign key in Sequelize
                                                                                                      Asked 2022-Jan-12 at 07:26

                                                                                                      I use sequelize ORM first time.

                                                                                                      when i made models of table, i worked well so, i could see this in GUI database.

                                                                                                      and this code is model of this table

                                                                                                      
                                                                                                      const Sequelize = require('sequelize');
                                                                                                      module.exports = (sequelize, DataTypes) => {
                                                                                                        class request extends Sequelize.Model {
                                                                                                      
                                                                                                      
                                                                                                          static associate(models) {
                                                                                                            models.request.belongsTo(models.model, {foreignKey: {name : "model_id", allowNull: true}})
                                                                                                            models.request.belongsTo(models.user, {foreignKey: {name : "user_id", allowNull: true}})
                                                                                                            models.request.hasOne(models.appraisal, {foreignKey: "request_id"})
                                                                                                          }
                                                                                                        };
                                                                                                      
                                                                                                      
                                                                                                      
                                                                                                        request.init({
                                                                                                          request_id : {
                                                                                                            type: Sequelize.INTEGER(11),
                                                                                                            allowNull: false,
                                                                                                            unique : true,
                                                                                                            autoIncrement: true,
                                                                                                            primaryKey: true,
                                                                                                          },
                                                                                                          request_time : {
                                                                                                            type : Sequelize.DATE,
                                                                                                          },
                                                                                                          image_folder : {
                                                                                                            type : Sequelize.STRING(64)
                                                                                                          },
                                                                                                          image_file : {
                                                                                                            type : Sequelize.STRING(256)
                                                                                                          },
                                                                                                          result : {
                                                                                                            type : Sequelize.STRING(8)
                                                                                                          },
                                                                                                          result_value : {
                                                                                                            type : Sequelize.INTEGER(8)
                                                                                                          },
                                                                                                          product_image : {
                                                                                                            type : Sequelize.STRING(64)
                                                                                                          }
                                                                                                        }, {
                                                                                                          sequelize,
                                                                                                          timestamps: true,
                                                                                                          underscored: false,
                                                                                                          modelName: 'request',
                                                                                                          tableName: 'request',
                                                                                                          paranoid: false,
                                                                                                          charset: 'utf8',
                                                                                                          collate: 'utf8_general_ci',
                                                                                                          freezeTableName: true,
                                                                                                          tableName: "request"
                                                                                                        });
                                                                                                        return request;
                                                                                                      };
                                                                                                      
                                                                                                      

                                                                                                      but, when i add record like this,

                                                                                                      const request = new db.request();
                                                                                                        let data = {
                                                                                                          request_time : date,
                                                                                                          image_folder : path,
                                                                                                          image_file : filesName,
                                                                                                          result : resultBool,
                                                                                                          result_value : resultValue,
                                                                                                          product_image : "8.jpg",
                                                                                                          model_id : 1,
                                                                                                          user_id : 1
                                                                                                        }
                                                                                                        db.request.create(data);
                                                                                                      

                                                                                                      it makes problem, Except for the foreign key, the values are successful inserted to columns, but foreign key doesn't get value. it always has null like this picture.

                                                                                                      How can i add value of foreign key in sequelize? :(

                                                                                                      ANSWER

                                                                                                      Answered 2022-Jan-12 at 07:26

                                                                                                      I suppose you need to indicate field option in associations along with name:

                                                                                                      foreignKey: {name : "model_id", field : "model_id", allowNull: true}
                                                                                                      

                                                                                                      If it still does not work then try to define model_id explicitly in the request model

                                                                                                      Source https://stackoverflow.com/questions/70351619

                                                                                                      QUESTION

                                                                                                      How to write url for testing when using viewsets in Django Restframework
                                                                                                      Asked 2022-Jan-08 at 09:49

                                                                                                      I am really noebie for testing. Actuall, I dont know how to write test url for getting response from viewsets. This is my views,

                                                                                                      class AppraisalAPI(viewsets.ReadOnlyModelViewSet):
                                                                                                          queryset = Appraisal.objects.all().order_by('-id')
                                                                                                          serializer_class = AppraisalSerializer
                                                                                                      
                                                                                                          def get_permissions(self):
                                                                                                              if self.action in ['retrieve']:
                                                                                                                  self.permission_classes = [IsHRUser | IsManagementUser]
                                                                                                              elif self.action in ['list']:
                                                                                                                  self.permission_classes = [IsUser]
                                                                                                              return super(self.__class__, self).get_permissions()
                                                                                                      
                                                                                                          def retrieve(self, request, *args, **kwargs):
                                                                                                              instance = self.get_object()
                                                                                                              data = instance.summary()
                                                                                                              return Response(data)
                                                                                                      

                                                                                                      This is my urls.py,

                                                                                                      router = routers.DefaultRouter()
                                                                                                      router.register('appraisal', AppraisalAPI)
                                                                                                      urlpatterns = [
                                                                                                          path('', include(router.urls)),
                                                                                                      ]
                                                                                                      

                                                                                                      This is my test function,

                                                                                                       def test_appraisal_api_readonly(self):
                                                                                                       url = reverse('appraisal-list')
                                                                                                              self.client = Client(HTTP_AUTHORIZATION='Token ' + token.key)
                                                                                                              resp1 = self.client.get(url, format='json')
                                                                                                              self.assertEqual(resp1.status_code, 200)
                                                                                                      

                                                                                                      This test url only went inside list action. when i give detail insteadof list it went only retrieve action. Here, I want to get Retrive function response, How can i get after getting permission i want to receive retrive function response. Anyhelp Appreciable,..

                                                                                                      ANSWER

                                                                                                      Answered 2022-Jan-08 at 09:49

                                                                                                      Since you use the DefaultRouter, you can trigger the retrieve action with appraisal-detail, and use a primary key of the object, so:

                                                                                                      def test_appraisal_api_readonly(self):
                                                                                                          url = reverse('appraisal-detail', kwargs={'pk': some_pk})
                                                                                                          self.client = Client(HTTP_AUTHORIZATION='Token ' + token.key)
                                                                                                          resp1 = self.client.get(url, format='json')
                                                                                                          self.assertEqual(resp1.status_code, 200)

                                                                                                      with some_pk the primary key (.pk) of some item you construct in the test.

                                                                                                      Source https://stackoverflow.com/questions/70631177

                                                                                                      QUESTION

                                                                                                      AttributeError: 'WebElement' object has no attribute 'Click' error trying to Click on a link using Selenium Python
                                                                                                      Asked 2021-Nov-30 at 05:42

                                                                                                      So I am in the process of trying to reach a search page which involves clicking on a clickable link on the bottom of the page. My code seems to be able to find the link or at least not throw an error when attempting to, however I get the error "AttributeError: 'WebElement' object has no attribute 'Click'" even though the element is physically clickable on the page. Here is the code and website.

                                                                                                      driver = webdriver.Edge(r'C:/Users/User/Desktop/Anaconda/edgedriver_win32/msedgedriver')
                                                                                                      driver.get("https://www.canada.ca/en/environment-climate-change/services/species-risk-public-registry/cosewic-assessments-status-reports")
                                                                                                      #click on the "Search COSEWIC status reports" button
                                                                                                      element = WebDriverWait(driver, 10).until(
                                                                                                          EC.presence_of_element_located((By.LINK_TEXT, "Search COSEWIC status reports"))
                                                                                                      )
                                                                                                      link = driver.find_element_by_link_text("Search COSEWIC status reports");
                                                                                                      link.Click();
                                                                                                      

                                                                                                      If I am wrong about this element being clickable please let me know. To be clear I am trying to click on the link "Search COSEWIC status reports found at the bottom of the webpage "https://www.canada.ca/en/environment-climate-change/services/species-risk-public-registry/cosewic-assessments-status-reports"

                                                                                                      Update

                                                                                                      I have found a workaround but the question still remains. I have run into another attribute that needs clicking and it doesn't seem to have attributes 'id' or anything easy to identify by.

                                                                                                      COSEWIC Status Appraisal Summary on the Pacific Water Shrew Sorex bendirii in Canada
                                                                                                      

                                                                                                      I have tried copying the XPath to this element and the id within the XPath but they don't seem to work. this is the first result on the page. "https://species-registry.canada.ca/index-en.html#/documents?documentTypeId=18&sortBy=documentTypeSort&sortDirection=asc&pageSize=10&keywords=pacific%20water%20shrew"

                                                                                                      ANSWER

                                                                                                      Answered 2021-Nov-30 at 05:42

                                                                                                      Your language bing is python so instead of Click() you need to use click()

                                                                                                      Additionally, to click on a clickable element instead of presence_of_element_located() you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

                                                                                                      driver = webdriver.Edge(r'C:/Users/User/Desktop/Anaconda/edgedriver_win32/msedgedriver')
                                                                                                      driver.get("https://www.canada.ca/en/environment-climate-change/services/species-risk-public-registry/cosewic-assessments-status-reports")
                                                                                                      #click on the "Search COSEWIC status reports" button
                                                                                                      WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "Search COSEWIC status reports"))).click()
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/70161503

                                                                                                      QUESTION

                                                                                                      Remove all punctuation from string
                                                                                                      Asked 2021-Nov-25 at 08:02

                                                                                                      I am currently working on a pandas dataframe and trying to extract the value from the column that consists of a string within a list, but I am kinda stuck on how to only keep the text I want.

                                                                                                      This is how one of list looks like:

                                                                                                      ["{'BusinessAcceptsCreditCards': 'True'",
                                                                                                       "'RestaurantsPriceRange2': '2'",
                                                                                                       "'ByAppointmentOnly': 'False'",
                                                                                                       "'BikeParking': 'False'",
                                                                                                       '\'BusinessParking\': "{\'garage\': False',
                                                                                                       "'street': True",
                                                                                                       "'validated': False",
                                                                                                       "'lot': False",
                                                                                                       '\'valet\': False}"}']
                                                                                                      

                                                                                                      On the left of the colon, it is the attribute and on the right of the colon, it is the corresponding value. Is there a way for me to go over this list and get rid of all the punctuations in each string and obtain the text only for both the attribute and the corresponding value?

                                                                                                      So my idea is to first break with the colon by using the following code:

                                                                                                      txt = df_business['attributes'][2]
                                                                                                      y = txt.split(", ")
                                                                                                      y
                                                                                                      y1 = y[0].split(":")
                                                                                                      y1
                                                                                                      y1[1].strip()
                                                                                                      

                                                                                                      But with the code I have above, I am only able to get the following result:

                                                                                                      Attribute = "{'BusinessAcceptsCreditCards'"
                                                                                                      Value = "'True'"
                                                                                                      

                                                                                                      The result I want is:

                                                                                                      Attribute = "BusinessAcceptsCreditCards"
                                                                                                      Value = "True"
                                                                                                      

                                                                                                      Example of the dataframe:

                                                                                                      {'business_id': {0: '6iYb2HFDywm3zjuRg0shjw',
                                                                                                        1: 'tCbdrRPZA0oiIYSmHG3J0w',
                                                                                                        2: 'bvN78flM8NLprQ1a1y5dRg',
                                                                                                        3: 'oaepsyvc0J17qwi8cfrOWg',
                                                                                                        4: 'PE9uqAjdw0E4-8mjGl3wVA',
                                                                                                        5: 'D4JtQNTI4X3KcbzacDJsMw',
                                                                                                        6: 't35jsh9YnMtttm69UCp7gw',
                                                                                                        7: 'jFYIsSb7r1QeESVUnXPHBw',
                                                                                                        8: 'N3_Gs3DnX4k9SgpwJxdEfw'},
                                                                                                       'name': {0: 'Oskar Blues Taproom',
                                                                                                        1: 'Flying Elephants at PDX',
                                                                                                        2: 'The Reclaimory',
                                                                                                        3: 'Great Clips',
                                                                                                        4: 'Crossfit Terminus',
                                                                                                        5: 'Bob Likes Thai Food',
                                                                                                        6: 'Escott Orthodontics',
                                                                                                        7: 'Boxwood Biscuit',
                                                                                                        8: 'Lane Wells Jewelry Repair'},
                                                                                                       'address': {0: '921 Pearl St',
                                                                                                        1: '7000 NE Airport Way',
                                                                                                        2: '4720 Hawthorne Ave',
                                                                                                        3: '2566 Enterprise Rd',
                                                                                                        4: '1046 Memorial Dr SE',
                                                                                                        5: '3755 Main St',
                                                                                                        6: '2511 Edgewater Dr',
                                                                                                        7: '740 S High St',
                                                                                                        8: '7801 N Lamar Blvd, Ste A140'},
                                                                                                       'city': {0: 'Boulder',
                                                                                                        1: 'Portland',
                                                                                                        2: 'Portland',
                                                                                                        3: 'Orange City',
                                                                                                        4: 'Atlanta',
                                                                                                        5: 'Vancouver',
                                                                                                        6: 'Orlando',
                                                                                                        7: 'Columbus',
                                                                                                        8: 'Austin'},
                                                                                                       'state': {0: 'CO',
                                                                                                        1: 'OR',
                                                                                                        2: 'OR',
                                                                                                        3: 'FL',
                                                                                                        4: 'GA',
                                                                                                        5: 'BC',
                                                                                                        6: 'FL',
                                                                                                        7: 'OH',
                                                                                                        8: 'TX'},
                                                                                                       'postal_code': {0: '80302',
                                                                                                        1: '97218',
                                                                                                        2: '97214',
                                                                                                        3: '32763',
                                                                                                        4: '30316',
                                                                                                        5: 'V5V',
                                                                                                        6: '32804',
                                                                                                        7: '43206',
                                                                                                        8: '78752'},
                                                                                                       'latitude': {0: 40.0175444,
                                                                                                        1: 45.5889058992,
                                                                                                        2: 45.5119069956,
                                                                                                        3: 28.9144823,
                                                                                                        4: 33.7470274,
                                                                                                        5: 49.2513423,
                                                                                                        6: 28.573998,
                                                                                                        7: 39.947006523,
                                                                                                        8: 30.346169},
                                                                                                       'longitude': {0: -105.2833481,
                                                                                                        1: -122.5933307507,
                                                                                                        2: -122.6136928797,
                                                                                                        3: -81.2959787,
                                                                                                        4: -84.3534244,
                                                                                                        5: -123.101333,
                                                                                                        6: -81.3892841,
                                                                                                        7: -82.997471,
                                                                                                        8: -97.711458},
                                                                                                       'stars': {0: 4.0,
                                                                                                        1: 4.0,
                                                                                                        2: 4.5,
                                                                                                        3: 3.0,
                                                                                                        4: 4.0,
                                                                                                        5: 3.5,
                                                                                                        6: 4.5,
                                                                                                        7: 4.5,
                                                                                                        8: 5.0},
                                                                                                       'review_count': {0: 86,
                                                                                                        1: 126,
                                                                                                        2: 13,
                                                                                                        3: 8,
                                                                                                        4: 14,
                                                                                                        5: 169,
                                                                                                        6: 7,
                                                                                                        7: 11,
                                                                                                        8: 30},
                                                                                                       'is_open': {0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1},
                                                                                                       'attributes': {0: '{\'RestaurantsTableService\': \'True\', \'WiFi\': "u\'free\'", \'BikeParking\': \'True\', \'BusinessParking\': "{\'garage\': False, \'street\': True, \'validated\': False, \'lot\': False, \'valet\': False}", \'BusinessAcceptsCreditCards\': \'True\', \'RestaurantsReservations\': \'False\', \'WheelchairAccessible\': \'True\', \'Caters\': \'True\', \'OutdoorSeating\': \'True\', \'RestaurantsGoodForGroups\': \'True\', \'HappyHour\': \'True\', \'BusinessAcceptsBitcoin\': \'False\', \'RestaurantsPriceRange2\': \'2\', \'Ambience\': "{\'touristy\': False, \'hipster\': False, \'romantic\': False, \'divey\': False, \'intimate\': False, \'trendy\': False, \'upscale\': False, \'classy\': False, \'casual\': True}", \'HasTV\': \'True\', \'Alcohol\': "\'beer_and_wine\'", \'GoodForMeal\': "{\'dessert\': False, \'latenight\': False, \'lunch\': False, \'dinner\': False, \'brunch\': False, \'breakfast\': False}", \'DogsAllowed\': \'False\', \'RestaurantsTakeOut\': \'True\', \'NoiseLevel\': "u\'average\'", \'RestaurantsAttire\': "\'casual\'", \'RestaurantsDelivery\': \'None\'}',
                                                                                                        1: '{\'RestaurantsTakeOut\': \'True\', \'RestaurantsAttire\': "u\'casual\'", \'GoodForKids\': \'True\', \'BikeParking\': \'False\', \'OutdoorSeating\': \'False\', \'Ambience\': "{\'romantic\': False, \'intimate\': False, \'touristy\': False, \'hipster\': False, \'divey\': False, \'classy\': False, \'trendy\': False, \'upscale\': False, \'casual\': True}", \'Caters\': \'True\', \'RestaurantsReservations\': \'False\', \'RestaurantsDelivery\': \'False\', \'HasTV\': \'False\', \'RestaurantsGoodForGroups\': \'False\', \'BusinessAcceptsCreditCards\': \'True\', \'NoiseLevel\': "u\'average\'", \'ByAppointmentOnly\': \'False\', \'RestaurantsPriceRange2\': \'2\', \'WiFi\': "u\'free\'", \'BusinessParking\': "{\'garage\': True, \'street\': False, \'validated\': False, \'lot\': False, \'valet\': False}", \'Alcohol\': "u\'beer_and_wine\'", \'GoodForMeal\': "{\'dessert\': False, \'latenight\': False, \'lunch\': True, \'dinner\': False, \'brunch\': False, \'breakfast\': True}"}',
                                                                                                        2: '{\'BusinessAcceptsCreditCards\': \'True\', \'RestaurantsPriceRange2\': \'2\', \'ByAppointmentOnly\': \'False\', \'BikeParking\': \'False\', \'BusinessParking\': "{\'garage\': False, \'street\': True, \'validated\': False, \'lot\': False, \'valet\': False}"}',
                                                                                                        3: "{'RestaurantsPriceRange2': '1', 'BusinessAcceptsCreditCards': 'True', 'GoodForKids': 'True', 'ByAppointmentOnly': 'False'}",
                                                                                                        4: '{\'GoodForKids\': \'False\', \'BusinessParking\': "{\'garage\': False, \'street\': False, \'validated\': False, \'lot\': False, \'valet\': False}", \'BusinessAcceptsCreditCards\': \'True\'}',
                                                                                                        5: '{\'GoodForKids\': \'True\', \'Alcohol\': "u\'none\'", \'RestaurantsGoodForGroups\': \'True\', \'RestaurantsReservations\': \'True\', \'BusinessParking\': "{\'garage\': False, \'street\': True, \'validated\': False, \'lot\': False, \'valet\': False}", \'RestaurantsAttire\': "u\'casual\'", \'BikeParking\': \'True\', \'RestaurantsPriceRange2\': \'2\', \'HasTV\': \'False\', \'NoiseLevel\': "u\'average\'", \'WiFi\': "u\'no\'", \'RestaurantsTakeOut\': \'True\', \'Caters\': \'False\', \'OutdoorSeating\': \'False\', \'Ambience\': "{\'romantic\': False, \'intimate\': False, \'classy\': False, \'hipster\': False, \'divey\': False, \'touristy\': False, \'trendy\': False, \'upscale\': False, \'casual\': True}", \'GoodForMeal\': "{\'dessert\': False, \'latenight\': False, \'lunch\': True, \'dinner\': True, \'brunch\': False, \'breakfast\': False}", \'DogsAllowed\': \'False\', \'RestaurantsDelivery\': \'True\'}',
                                                                                                        6: "{'AcceptsInsurance': 'True', 'BusinessAcceptsCreditCards': 'True', 'ByAppointmentOnly': 'True'}",
                                                                                                        7: nan,
                                                                                                        8: '{\'RestaurantsPriceRange2\': \'1\', \'ByAppointmentOnly\': \'False\', \'BusinessParking\': "{\'garage\': False, \'street\': False, \'validated\': False, \'lot\': True, \'valet\': False}", \'BusinessAcceptsCreditCards\': \'True\', \'DogsAllowed\': \'True\', \'RestaurantsDelivery\': \'None\', \'BusinessAcceptsBitcoin\': \'False\', \'BikeParking\': \'True\', \'RestaurantsTakeOut\': \'None\', \'WheelchairAccessible\': \'True\'}'},
                                                                                                       'categories': {0: 'Gastropubs, Food, Beer Gardens, Restaurants, Bars, American (Traditional), Beer Bar, Nightlife, Breweries',
                                                                                                        1: 'Salad, Soup, Sandwiches, Delis, Restaurants, Cafes, Vegetarian',
                                                                                                        2: 'Antiques, Fashion, Used, Vintage & Consignment, Shopping, Furniture Stores, Home & Garden',
                                                                                                        3: 'Beauty & Spas, Hair Salons',
                                                                                                        4: 'Gyms, Active Life, Interval Training Gyms, Fitness & Instruction',
                                                                                                        5: 'Restaurants, Thai',
                                                                                                        6: 'Dentists, Health & Medical, Orthodontists',
                                                                                                        7: 'Breakfast & Brunch, Restaurants',
                                                                                                        8: 'Shopping, Jewelry Repair, Appraisal Services, Local Services, Jewelry, Engraving, Gold Buyers'},
                                                                                                       'hours': {0: "{'Monday': '11:0-23:0', 'Tuesday': '11:0-23:0', 'Wednesday': '11:0-23:0', 'Thursday': '11:0-23:0', 'Friday': '11:0-23:0', 'Saturday': '11:0-23:0', 'Sunday': '11:0-23:0'}",
                                                                                                        1: "{'Monday': '5:0-18:0', 'Tuesday': '5:0-17:0', 'Wednesday': '5:0-18:0', 'Thursday': '5:0-18:0', 'Friday': '5:0-18:0', 'Saturday': '5:0-18:0', 'Sunday': '5:0-18:0'}",
                                                                                                        2: "{'Thursday': '11:0-18:0', 'Friday': '11:0-18:0', 'Saturday': '11:0-18:0', 'Sunday': '11:0-18:0'}",
                                                                                                        3: nan,
                                                                                                        4: "{'Monday': '16:0-19:0', 'Tuesday': '16:0-19:0', 'Wednesday': '16:0-19:0', 'Thursday': '16:0-19:0', 'Friday': '16:0-19:0', 'Saturday': '9:0-11:0'}",
                                                                                                        5: "{'Monday': '17:0-21:0', 'Tuesday': '17:0-21:0', 'Wednesday': '17:0-21:0', 'Thursday': '17:0-21:0', 'Friday': '17:0-21:0', 'Saturday': '17:0-21:0', 'Sunday': '17:0-21:0'}",
                                                                                                        6: "{'Monday': '0:0-0:0', 'Tuesday': '8:0-17:30', 'Wednesday': '8:0-17:30', 'Thursday': '8:0-17:30', 'Friday': '8:0-17:30'}",
                                                                                                        7: "{'Saturday': '8:0-14:0', 'Sunday': '8:0-14:0'}",
                                                                                                        8: "{'Monday': '12:15-17:0', 'Tuesday': '12:15-17:0', 'Wednesday': '12:15-17:0', 'Thursday': '12:15-17:0', 'Friday': '12:15-17:0'}"}}
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2021-Nov-25 at 08:02

                                                                                                      I want to count the number of time that True and False shows up in each restaurant attribute

                                                                                                      You can concatenate all elements of you list and search for the '\bTrue\b' /'\bFalse\b' patterns (\b denotes word boundaries):

                                                                                                      s = df['attributes'].fillna('').apply(''.join)
                                                                                                      df['nb_True'] = s.str.count(r'\bTrue\b')
                                                                                                      df['nb_False'] = s.str.count(r'\bFalse\b')
                                                                                                      

                                                                                                      output:

                                                                                                      >>> df[['nb_True', 'nb_False']]
                                                                                                         nb_True  nb_False
                                                                                                      0       12        21
                                                                                                      1        8        23
                                                                                                      2        2         6
                                                                                                      3        2         1
                                                                                                      4        1         6
                                                                                                      5       10        20
                                                                                                      6        3         0
                                                                                                      7        0         0
                                                                                                      8        5         6
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/70092908

                                                                                                      QUESTION

                                                                                                      Handle uncompleted file upload by API POST endpoint in asp.net core MVC
                                                                                                      Asked 2021-Nov-03 at 19:06

                                                                                                      To simplify the problem let's say I have a simple asp.net mvc endpoint which receives a file. In most of the cases it will be a .jpg one:

                                                                                                      [HttpPost]
                                                                                                      [Route("appraisal/{appraisalID}/files/{fileSubjectCode}")]
                                                                                                      [ProducesResponseType(StatusCodes.Status201Created, Type = typeof(IEnumerable))]
                                                                                                      [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ModelStateDictionary))]
                                                                                                      public async Task UploadAppraisalFile(int appraisalID, string fileSubjectCode, [FromForm]IFormFile file)
                                                                                                      {
                                                                                                              file = file ?? Request.Form.Files?.FirstOrDefault();
                                                                                                      
                                                                                                              // intermitent code change to investigate and validate Complete File Size and Actual File Size
                                                                                                              var completeFileSizeHeader = Request.Headers["Complete-File-Size"];
                                                                                                              int.TryParse(completeFileSizeHeader, out int completeFileSize);
                                                                                                      
                                                                                                              if (file == null || file.Length != completeFileSize)
                                                                                                              {
                                                                                                                  using (var stream = new MemoryStream())
                                                                                                                  {
                                                                                                                      await file.CopyToAsync(stream);
                                                                                                                      stream.Position = 0;
                                                                                                      
                                                                                                                      var inputAsString = Convert.ToBase64String(stream.ToArray());
                                                                                                                      Logger.LogDebug("Complete-File-Size header doesn't much received byteArray size", file.Length, completeFileSize, inputAsString);
                                                                                                                  }
                                                                                                                  return StatusCode(StatusCodes.Status411LengthRequired, "Complete-File-Size header doesn't much received byteArray size");
                                                                                                              }
                                                                                                      
                                                                                                      
                                                                                                              // some other logic..
                                                                                                      }
                                                                                                      

                                                                                                      I'm trying to prevent an edge case when somebody performs a POST request against my API UploadAppraisalFile endpoint and suddenly loses an internet connection which would result in sending a request with not the full file content. My idea was to count the file size at the point where the file is uploaded, add the information about the file size as an extra HTTP-HEADER (I called it Complete-File-Size), and then when the request reaches the backend, count if the received file size is exactly the same as the Complete-File-Size.

                                                                                                      To produce such an issue/edge case I tried:

                                                                                                      • uploading a big file(about 16MB) and then suddenly after submitting the HTML form immediately close the browser window.
                                                                                                      • uploading a file and then, in the Chrome browser, in the Network pane, change the uploading speed to a very minimum, then submit the form and then immediately close the browser.

                                                                                                      When I run the debug mode, in each case I found that either: UploadAppraisalFile endpoint was never reached or if it was reached then always the full file was sent. For the 2nd successful case, to be 100% sure I converted the received file into base64 string and then I checked how the file looks like in https://codebeautify.org/base64-to-image-converter.

                                                                                                      My question is: Is it even possible that the sent POST request is broken and contains not full file content due to a broken internet connection that happened suddenly during the sending process? If yes, then what's the best way to produce the issue. Cheers

                                                                                                      ANSWER

                                                                                                      Answered 2021-Nov-03 at 19:06

                                                                                                      You can pass HttpContext.RequestAborted as a CancellationToken to ALL async methods provided by .NET in "some other logic" part.

                                                                                                      Let's use code you provided as an example :

                                                                                                      await stream.CopyToAsync(memoryStream, HttpContext.RequestAborted)
                                                                                                      

                                                                                                      I don't have an access to a full method but I assume you save it to some blob storage or file system. Most of these persistence API's accept CancellationToken as a parameter.

                                                                                                      Receiving incomplete file

                                                                                                      I was able to achieve a "partial" file using this code and Postman. It will basically read chunks from response stream until connection is interrupted. As soon as I close Postman window TaskCancelledException is raised and stream is closed.

                                                                                                      [HttpPost]
                                                                                                      public async Task UploadAppraisalFile([FromForm] IFormFile file)
                                                                                                      {
                                                                                                          var appraisalfile = file ?? Request.Form.Files.FirstOrDefault();
                                                                                                      
                                                                                                          if (appraisalfile != null)
                                                                                                          {
                                                                                                              var buffer = ArrayPool.Shared.Rent(1024);
                                                                                                              using var stream = appraisalfile.OpenReadStream();
                                                                                                              while (await stream.ReadAsync(buffer, 0, buffer.Length, HttpContext.RequestAborted) > 0)
                                                                                                              {
                                                                                                                   // Do something with buffer
                                                                                                                   _logger.LogInformation("Total length (bytes) {0}, partial length (bytes) {1}", stream.Length, stream.Position);
                                                                                                              }
                                                                                                              ArrayPool.Shared.Return(buffer);
                                                                                                          }
                                                                                                      
                                                                                                          return Ok();
                                                                                                      }
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/69769987

                                                                                                      QUESTION

                                                                                                      How to access SSM Parameter Store from SAM lambda local in node
                                                                                                      Asked 2021-Apr-29 at 17:20

                                                                                                      I have a lambda with node and for local deployment I am using SAM CLI. This lambda requires some parameters in the SSM parameter store to be able to connect to the DB. I configured the AWS_ACCES_KEY_ID and AWS_SECRET_ACCESS_KEY, as environment variables, in addition to the region. When executing the local lamda, I do not get any error, as it goes to aws, but it does not bring me anything. It is not a code issue, because if I deploy it already in aws it works without problem. I don't know if I need to do another configuration for it to work.

                                                                                                      template.yaml

                                                                                                      AWSTemplateFormatVersion: '2010-09-09'
                                                                                                      Transform: AWS::Serverless-2016-10-31
                                                                                                      Description: >
                                                                                                        ciencuadras-appraisal-request
                                                                                                      
                                                                                                        Sample SAM Template for ciencuadras-appraisal-request
                                                                                                      
                                                                                                      Parameters:
                                                                                                        Stage:
                                                                                                          Type: String
                                                                                                          Default: dev
                                                                                                          
                                                                                                      # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
                                                                                                      Globals:
                                                                                                        Function:
                                                                                                          Timeout: 3
                                                                                                      
                                                                                                      Resources:
                                                                                                        ApiDeployment:
                                                                                                          Type: AWS::Serverless::Api
                                                                                                          Properties:
                                                                                                            StageName: !Ref Stage
                                                                                                      
                                                                                                        RequestAppraisalFunction:
                                                                                                          Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction    
                                                                                                          Properties:
                                                                                                            CodeUri: dist/
                                                                                                            Handler: main.handler
                                                                                                            Runtime: nodejs14.x
                                                                                                            Environment:
                                                                                                              Variables:
                                                                                                                AWS_REGION: 'us-east-1'    
                                                                                                            Events:
                                                                                                              RequestAppraisal:
                                                                                                                Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
                                                                                                                Properties:
                                                                                                                  Path: /sendemail-new-appraisal
                                                                                                                  Method: post
                                                                                                                  RestApiId: !Ref ApiDeployment
                                                                                                      

                                                                                                      Thanks

                                                                                                      ANSWER

                                                                                                      Answered 2021-Apr-29 at 17:20

                                                                                                      Currently there is no possibility to access Parameter Store variables from Sam Local as you can read up here.

                                                                                                      Instead, you can use --env-vars option on SAM CLI to pass values to the running function.

                                                                                                      Source https://stackoverflow.com/questions/67322185

                                                                                                      QUESTION

                                                                                                      HTML place divs on same level
                                                                                                      Asked 2021-Apr-23 at 18:47

                                                                                                      I currently have the following html page showing notification and alerts (models in my db )

                                                                                                      Html code :

                                                                                                         {% extends 'users/base.html' %} {% load static %} {% block content %}
                                                                                                      
                                                                                                          
                                                                                                            Select Site
                                                                                                          {% for site in thesites %}
                                                                                                              {{ site.site }}
                                                                                                          {% endfor %}
                                                                                                          
                                                                                                        
                                                                                                      

                                                                                                      {{site_name}}
                                                                                                      {% for notification in on_track %} {{notification.kpi}} {{notification.value}}% {% endfor %} {% for alert in alerts %} {{alert.kpi}} {{alert.value}}% {% endfor %}
                                                                                                      {% endblock content %}

                                                                                                      I would like to have employee satisfactionra rate go up to the level of turn over and suggestion implementation rate to go to performance appraisal completion rate. I am new to css so please help me

                                                                                                      ANSWER

                                                                                                      Answered 2021-Apr-23 at 18:47

                                                                                                      If you’re using BootStrap Grid System- which I can see in the code. You can simply use class=“row” to place divs under one another

                                                                                                      Source https://stackoverflow.com/questions/67235305

                                                                                                      QUESTION

                                                                                                      How can I listen for a Service variable change in a component in Angular
                                                                                                      Asked 2021-Apr-05 at 21:55

                                                                                                      I have a component with a button that triggers showSummary() when clicked that calls a service Appraisal-summary.service.ts that has a method calc()

                                                                                                      showSummary(appraisal) {
                                                                                                        this.summaryService.calc(appraisal);
                                                                                                      }
                                                                                                      

                                                                                                      with service Appraisal-summary.service.ts :

                                                                                                      calc(appraisal) {
                                                                                                        ...
                                                                                                        //a 'scores' array is created (synchronously)
                                                                                                        return this.scores;
                                                                                                      }
                                                                                                      

                                                                                                      How do I listen for the synchronous result this.scores to trigger a function in an unrelated component summary.component.ts (that has already been initialised) that will use scores.

                                                                                                      something like: summary.component.ts:

                                                                                                      ngOnInit(): void {
                                                                                                        service.subscribe(scores => this.data = scores)
                                                                                                      }
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2021-Apr-05 at 21:55

                                                                                                      You would want to add a Subject inside your Appraisal-summary.service.ts like this:

                                                                                                      import { Subject } from 'rxjs';
                                                                                                      
                                                                                                      ...
                                                                                                      export class AppraisalSummaryService {
                                                                                                          // I am guessing scores is an array of type number
                                                                                                          public scoreSubject = new Subject(); 
                                                                                                          
                                                                                                          calc(appraisal) {
                                                                                                            ...
                                                                                                            //a 'scores' array is created (synchronously)
                                                                                                            
                                                                                                            this.scoreSubject.next(this.scores); //emit the scores result
                                                                                                            return this.scores;
                                                                                                         }
                                                                                                      }
                                                                                                      
                                                                                                      

                                                                                                      And, in your other component, inside your ngOnInit, you want to listen to this result:

                                                                                                      import { Subscription } from 'rxjs';
                                                                                                      ....
                                                                                                      export class YourOtherComponent implements OnInit, OnDestroy {
                                                                                                         private subscription: Subscription;
                                                                                                      
                                                                                                         constructor(private appraisalSummaryService: AppraisalSummaryService) {}
                                                                                                      
                                                                                                         public ngOnInit(): void {
                                                                                                           // you store your subscribe
                                                                                                           this.subscription = this.appraisalSummaryService.subscribe((scores: number[]) => {
                                                                                                             console.log(scores);
                                                                                                          });
                                                                                                         }
                                                                                                         
                                                                                                         public onDestroy(): void {
                                                                                                           // you need this in order to avoid a memory leak
                                                                                                           this.subscription.unsubscribe();
                                                                                                         }
                                                                                                         
                                                                                                      }
                                                                                                      ```
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/66959903

                                                                                                      QUESTION

                                                                                                      How do I load nested entities in entity framework when they cross reference each other?
                                                                                                      Asked 2021-Mar-11 at 11:30

                                                                                                      This one is a bit complicated so I've created a sample project (instructions in the readme)

                                                                                                      https://github.com/dominicshaw/EntityFrameworkNestingQuirk

                                                                                                      I have the following code:

                                                                                                      private async Task<(bool Found, Appraisal Appraisal)> Get(int id)
                                                                                                      {
                                                                                                          var staff = await _context.Staff.FindAsync(3);
                                                                                                      
                                                                                                          _logger.LogInformation("Got Staff Object   : Staff {id} has manager set to {managerId} - running query for appraisal", staff.Id, staff.ManagerId);
                                                                                                      
                                                                                                          var appraisal =
                                                                                                              await _context.Appraisals
                                                                                                                  .Include(ap => ap.Staff).ThenInclude(s => s.Manager)
                                                                                                                  .Include(ap => ap.Staff).ThenInclude(s => s.SecondaryManager)
                                                                                                                  .Where(ap => ap.Id == id)
                                                                                                                  .SingleOrDefaultAsync();
                                                                                                      
                                                                                                          _logger.LogInformation("Appraisal Query Run: Staff {id} has manager set to {managerId} - run completed", staff.Id, staff.ManagerId);
                                                                                                      
                                                                                                          if (appraisal != null)
                                                                                                          {
                                                                                                              _logger.LogInformation("Appraisal->Staff->2ndManager->Manager={id} (We should NOT have this)", appraisal.Staff.SecondaryManager?.ManagerId);
                                                                                                              return (true, appraisal);
                                                                                                          }
                                                                                                      
                                                                                                          return (false, null);
                                                                                                      }
                                                                                                      

                                                                                                      The data is never written to and staff id 3 has two managers, both set at the point of the first logged line.

                                                                                                      I then grab the appraisal for this staff member from the database - the query ef generates looks good and brings back both managers, however in running that query, I lose the manager id (which should be 1) on the staff object (3).

                                                                                                      When the second log is hit, the managerid is null.

                                                                                                      I note that the EF model has loaded the secondary manager of the manager even though I didn't ask it to (unless my ef query syntax is wrong?). The manager (1) is manager of both 2 and 3, so this is correct, but it should have been loaded into Appraisal->Staff->Manager, not Appraisal->Staff->SecondaryManager->Manager

                                                                                                      Any ideas how I can resolve this?

                                                                                                      ANSWER

                                                                                                      Answered 2021-Mar-11 at 11:30

                                                                                                      The issue is that EF Core thinks that the Manager and SecondaryManager self-referencing relationships are one-to-one relationships, which further means it thinks it can only assign a given entity to a single navigational property.

                                                                                                      The following OnModelCreating() configuration solved the issue for me locally. Only the commented lines are changed compared to the configuration you provided:

                                                                                                      builder.Entity().HasIndex(e => e.ManagerId).IsUnique(false);
                                                                                                          builder.Entity()
                                                                                                              .HasOne(a => a.Manager)
                                                                                                              .WithMany() // Changed
                                                                                                              .HasForeignKey(s => s.ManagerId)
                                                                                                              .IsRequired(false)
                                                                                                              .OnDelete(DeleteBehavior.NoAction);
                                                                                                          
                                                                                                          builder.Entity().HasIndex(e => e.SecondaryManagerId).IsUnique(false);
                                                                                                          builder.Entity()
                                                                                                              .HasOne(a => a.SecondaryManager)
                                                                                                              .WithMany() // Changed
                                                                                                              .HasForeignKey(s => s.SecondaryManagerId)
                                                                                                              .IsRequired(false)
                                                                                                              .OnDelete(DeleteBehavior.NoAction);
                                                                                                      
                                                                                                      
                                                                                                      Why is the nested Manager populated?

                                                                                                      The reason for this is the 'relationship fix-up' behavior of EF Core, which means if you load an entity that is referenced by a navigation property, it automatically assigns that entity to the given navigation property.

                                                                                                      Even if you run two completely separate queries, if there is a relational connection between the separately loaded entities, EF Core will connect them together in memory.

                                                                                                      In this example, both the main Manager and the nested Manager references the same Staff entity with Id 1, so it would 'fix up' both in memory. But, it happens to 'fix up' the nested one first, and given the one-to-one constraint I suppose it simply stops there. Perhaps someone with a deeper understanding of the inner workings of EF Core will enlighten us with more details.

                                                                                                      Source https://stackoverflow.com/questions/66566175

                                                                                                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                                                                                                      Vulnerabilities

                                                                                                      No vulnerabilities reported

                                                                                                      Install appraisal

                                                                                                      In your package’s .gemspec:. Note that gems must be bundled in the global namespace. Bundling gems to a local location or vendoring plugins is not supported. If you do not want to pollute the global namespace, one alternative is [RVM’s Gemsets](http://rvm.io/gemsets).
                                                                                                      Setting up appraisal requires an Appraisals file (similar to a Gemfile) in your project root, named "Appraisals" (note the case), and some slight changes to your project’s Rakefile.

                                                                                                      Support

                                                                                                      For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
                                                                                                      Find more information at:
                                                                                                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                                      Find more libraries
                                                                                                      Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                                      Save this library and start creating your kit
                                                                                                      CLONE
                                                                                                    • HTTPS

                                                                                                      https://github.com/thoughtbot/appraisal.git

                                                                                                    • CLI

                                                                                                      gh repo clone thoughtbot/appraisal

                                                                                                    • sshUrl

                                                                                                      git@github.com:thoughtbot/appraisal.git

                                                                                                    • Share this Page

                                                                                                      share link

                                                                                                      Consider Popular Continous Integration Libraries

                                                                                                      Try Top Libraries by thoughtbot

                                                                                                      guides

                                                                                                      by thoughtbotRuby

                                                                                                      bourbon

                                                                                                      by thoughtbotRuby

                                                                                                      paperclip

                                                                                                      by thoughtbotRuby

                                                                                                      laptop

                                                                                                      by thoughtbotShell

                                                                                                      factory_bot

                                                                                                      by thoughtbotRuby

                                                                                                      Compare Continous Integration Libraries with Highest Support

                                                                                                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                                      Find more libraries
                                                                                                      Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                                      Save this library and start creating your kit